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
onSubmit being called before validation #156
Comments
First of all, questions should go on stackoverflow, reactiflux etc. (at Secondly, don't pass onSubmit to handleSubmit, it already takes care of On Wed, Oct 21, 2015, 2:13 AM Adam Duro notifications@github.com wrote:
Wout. |
I already tried not passing onSubmit explicitly. Same issue. So far this is appearing bug like, hence submitting an issue. On Tuesday, October 20, 2015, Wout Mertens notifications@github.com wrote:
|
Then you should have said so from the start, saving all of us time :-) Are you sure the validate is not running, I don't see a console log? On Wed, Oct 21, 2015, 7:31 AM Adam Duro notifications@github.com wrote:
Wout. |
I have been using the debugger with breakpoints. The validate breakpoint is On Tuesday, October 20, 2015, Wout Mertens notifications@github.com wrote:
|
Indeed the submit gets called before a final validate. However the validate should have been called on change already? @erikras not sure what the rationale is here… On Wed, Oct 21, 2015, 7:54 AM Adam Duro notifications@github.com wrote:
Wout. |
Sync validation is called on every render. Or at least it should be. |
apart from that, why does the validate get called after submitting in On Wed, Oct 21, 2015 at 3:56 PM Erik Rasmussen notifications@github.com
Wout. |
@erikras I can understand validation running on every render, but what I don't understand is why the submit handler is being called before validation. It should work like this: Submit Click -> Validation Fail -> Render Right now it is working like: Submit Click -> Submit Handler -> Validation Success/Fail -> Render Doesn't make sense since the submit handler should only run if the form is valid. |
This was primarily user error. My validation rules were always telling redux-form that the form was valid. |
😆 Okay, no problem. My change won't break anything. |
In my case, |
The field-level validation it doesn't work. The onSubmit handler is called before the validation which seems wrong. There was already an issue on the repo about it: redux-form/redux-form#156 but with no specific solution. This reuses the required validation function to validate all fields of the form, which does happend before onSubmit is called.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Here is a simple form component I have setup.
Here is the main page container:
And here is the LoginForm.js container/component:
The problem I am running into is that the
handleSubmit
in the parent container is getting called before thevalidateLogin
function is called and validations have either happened successfuly, or not.My expection is that the validator function would get called, and if there were no errors, then the
handleSubmit
that I passed in from theonSubmit
prop would get called.Am I doing something wrong, have the wrong expectation, or is this a bug?
The text was updated successfully, but these errors were encountered: