Destroy then initialize does not respect validation on consecutive submissions
See original GitHub issueI have an edit profile page with a simple name/email/password form. Let’s say the user changes their name, then hits save. If they then change their name again and hit save, it won’t validate anything (i.e., they can submit a blank name which is supposed to be required, or a password under the minimum length, etc.)
I’m handling side effects using redux-saga, so I call startSubmit, stopSubmit, and destroy separately.
However, after this form is destroyed, I do an initialize with the server’s responded values to re-initialize it.
For some reason, destroy gets rid of validation. How do I initialize after the destroy, and pass validation to it? My handleSubmit (which is declared via onSubmit in the reduxForm method in the component) still works fine, but validation does not.
Again, validation works fine on first submission. But after destroy, it doesn’t work any longer.
So, to diagram this flow:
1. User enters fields and clicks save.
2. Form validates input
3. Form submits
4. I intercept with onSubmit and manually call startSubmit
5. If successful, I call stopSubmit.
6. Then I call destroy.
7. Then I call initialize.
8. User changes fields and clicks save again.
9. Form validates input but does not respect it (aka I can log from my validate method and see it's being called, but the form ignores the errors and submits anyway).
10. Form submits
Number 10 should not happen.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top GitHub Comments
Any update on this? I’m experience the same issue on version 7.1.2 using React 15.6.2 and Redux 3.7.2. Where after calling destroy, the form will submit regardless of if there are any
syncErrors
sitting in the form stateFor all of you using
redux-saga
, perhaps check out this tool I just built to convert actions into aPromise
for libraries likeredux-form
.