Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

How to reset form? #39

Closed
iltera opened this issue Jun 15, 2015 · 6 comments
Closed

How to reset form? #39

iltera opened this issue Jun 15, 2015 · 6 comments

Comments

@iltera
Copy link

iltera commented Jun 15, 2015

I'm trying to reset form to it's pristine state, but cannot succeed. I looked for a working example here, but couldn't find that either. I am changing all the input values to empty text (""), and then calling myform.$setPristine(); I think that is the way to do it. But the $setPrisitine() doesn't seem to do anything.

Can anyone guide me where to check or what could be the issue?

@iltera
Copy link
Author

iltera commented Jun 15, 2015

Added $setUntounched() and I guess it works now :)

@iltera iltera closed this as completed Jun 15, 2015
@ghiscoding
Copy link
Owner

Hello, yes I use the $touched especially for showing errors on an empty form. For example, looking at this functionality on the Wiki - Pre-Validate Form on Page Load is done using the $touched as you found out.

I could had a comment in the Wiki documentation if you want, but yes that is the correct way of resetting a form.

Thanks for using it ;)

@ghiscoding
Copy link
Owner

Added a Wiki - Reset Form, that should explain it well. Let me know if you have other comments about it. :)

Actually I did not try it, but does it reset the $touched on each input element as well? I hope it does, else I will have to make another function in the Service.

@ghiscoding
Copy link
Owner

Ok I tried it and that is actually not enough, doing the $setUntouched() and $setPristine() does not remove the errors displayed (if any).

I will re-open this issue and add a new function in the Service, should be done in the next couple days. Since I also add Protractor tests, it's a bit longer to do both.

Thanks for the feedback

@ghiscoding
Copy link
Owner

This functionality was added in v1.3.31, there is a lot more options than I imagined at first. So the possible options you can pass the function should cover all cases.

Make sure to update to latest v1.3.31 to see the changes
Enjoy ;)

@iltera
Copy link
Author

iltera commented Jun 23, 2015

@ghiscoding, thank you for taking time to take a look at this issue. I will try the new version when I'll have time. If anything comes up, will report back here. Thanks again! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants