angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

Set field dirty and not valid

Open jdgblinq opened this issue 12 years ago • 3 comments

I need to be able to set a field as $dirty = true and $setValidity(e,false), as per this guide: http://fdietz.github.io/recipes-with-angular-js/backend-integration-with-ruby-on-rails/validating-forms-server-side.html

How do I do that with angular-schema-form? I see how to set the form as $dirty, but how do I set an individual field?

Thanks

jdgblinq avatar Dec 02 '14 16:12 jdgblinq

I'll be surprised if these changes are acceptable. In particular, the model[key + '_error'] change seems a bit hackish to me, but I couldn't think of a better way to do it. I'm open to suggestions. This did solve my problem on my end, allowing me to pass server side errors through to schemaForm on a specific field.

jdgblinq avatar Dec 03 '14 13:12 jdgblinq

Exposing $$key$$ and setting the name attribute like you did would be useful by itself. Then, in the submit callback we will be able to call myForm['fieldName'].$setValidity(...).

rhelgeby avatar Jan 06 '15 16:01 rhelgeby

@jdgblinq I agree that model[key + '_error'] looks a bit hackish :-) I'll try to get time to check out the PR today or tomorrow

davidlgj avatar Jan 07 '15 09:01 davidlgj