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
Allow validateOnSubmit #414
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you submitting a bug report or a feature request?
This is a feature request and I'm willing to provide a PR.
What is the current behavior?
When submitting a form, e. g. by writing into an input field and triggering enter, validation is not triggered. With
validateOnBlur
, this means that the field is never validated before submission.Submission is blocked, though, if there are already errors in the form state. This means that when I have a form with errors, fix the errors and submit by pressing enter, then the submission will fail as validation did not run again.
This cannot be fixed outside the library, as the
onSubmit
andbeforeSubmit
hooks would only get called afterhasSyncErrors
already cancelled the execution.What is the expected behavior?
Introduce a config flag
validateOnSubmit
that, if set, runs validation instead of callinghasSyncErrors
insubmit
.Sandbox Link
https://codesandbox.io/s/react-final-form-simple-example-forked-pgdml?file=/index.js
What's your environment?
Tested with react-final-form
6.5.2
and final-form4.20.1
.Other information
Happy to contribute a PR if this feature is of interest.
Other related issues:
The text was updated successfully, but these errors were encountered: