Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear hasError state when resetting? #613

Closed
jacobweberbowery opened this issue Sep 29, 2022 · 3 comments
Closed

Clear hasError state when resetting? #613

jacobweberbowery opened this issue Sep 29, 2022 · 3 comments

Comments

@jacobweberbowery
Copy link

jacobweberbowery commented Sep 29, 2022

Hi. I have a form where all fields are required, and their default values are empty. I'm using hasError in my bindings to indicate which fields have errors.

I don't want errors to appear until the user at least focuses a field, so I set validateOnInit: false.

But when I reset the form to its initial values using form.reset(), I want to put it back in that initial state, so the errors no longer appear.

I tried setting showErrorsOnReset: false, and this prevents the error text from appearing. But the hasError property still becomes true. Is there a way to prevent this?

@nickryall
Copy link

I have the same issue. A workaround we use for now is

form.reset();
form.each(field => field.resetValidation());

@foxhound87
Copy link
Owner

foxhound87 commented Mar 12, 2023

resetValidation() is now performed on reset and clear instead of validate()

Also introduced validateOnClear & validateOnReset form options (disabled by default).

@jacobweberbowery
Copy link
Author

Thanks!

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

No branches or pull requests

3 participants