Field validation not triggered after reset
See original GitHub issueVery easy to reproduce:
https://codesandbox.io/s/o22j1lOZB
Modify age, then reset, then modify age, then submit.
Field validation on Username
and Email
are bypassed.
UPDATE_SYNC_ERRORS
is not triggered after reset like it is when a validated field is dirty.
It looks like the conditions updateSyncErrorsIfNeeded
are incorrects.
This is a major issue IMO. I have no easy workaround. @erikras I know you must be terribly busy but can you have a look?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:18 (5 by maintainers)
Top Results From Across the Web
Validation not working after clear the form - Stack Overflow
After resetting the form you are running validations manually by calling setErrors(null). setErrors(null) means you are setting the form ...
Read more >Reactive Form - Reset input validation after change
I believe the reason your Form wasn't resetting was because of the 'Built-In Validations' Property of your Delete button. When set to 'Built-In...
Read more >NgForm - Angular
Method called when the "reset" event is triggered on the form. onReset(): void. Parameters.
Read more >useForm - reset - React Hook Form
For controlled components you will need to pass defaultValues to useForm in order to reset the Controller components' value. When defaultValues is not...
Read more >Handling Forms - VeeValidate
In case you want to perform some logic after a form fails to submit due to validation errors (e.g: focusing the first invalid...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I confirm, the problem is not solved yet, after the reset, verification is not carried out…
p.s. v6.8.0
Same problem happening here. We have an edit mode and read only mode and have an issue with resetting the form. We have two different behaviors happening Behavior 1 (CORRECT): Enter edit mode, update any form value, leave edit mode (reset() is called). formSyncErrors contains all errors of the wrong fields. Behavior 2 (WRONG): Enter edit mode, don’t update any form value, leave edit mode (reset() is called). formSyncErrors contains no fields, but before reset call it did, so it’s being reset somewhere.
for now we found a workaround:
//reset();
initialize(originalData);
This is working, since initialize will trigger the validation
UPDATE_SYNC_ERRORS
message.p.s. may require
enableReinitialize: true, keepDirtyOnReinitialize: true