-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Submit validation failed #256
Comments
The other option would be to have handleSubmit always call a function and allow that function to manually call the relevant validation functions. That way the end user has totally control. |
The current system provides enough control, I think. How about something like this? <form onSubmit={handleSubmit(() =>
mySubmitAction()
.then(() => {
// submission was successful
}, errors => {
// submission was unsuccessful
// set showIntenseErrors and scroll to first invalid input
}))}>
// render inputs
</form> |
yep perfect On 12 November 2015 at 04:48, Erik Rasmussen notifications@github.com
|
Sorry I'm a little confused. On validation failure (I'm using async) the Am I missing something? Should the .then tack on to handleSubmit ? On 12 November 2015 at 09:23, Erik Rasmussen notifications@github.com
|
Here is my code:
|
You're using the |
Yep got that. I'm also using asyncBlurFields so I can't tell in my So I was wondering how do you feel about an onSubmitFailed prop(erty)? or If your into the idea I'll try to send you a pull request. On 13 November 2015 at 04:50, Erik Rasmussen notifications@github.com
|
<form onSubmit={event =>
handleSubmit(mySubmitAction)(event) // <---- this is the promise returned from handleSubmit()
.then(() => {
// submission was successful
}, errors => {
// submission was unsuccessful
}))}>
// render inputs
</form> You will always get to one of those two code branches if the user clicks submit. |
Unfortunately I'm not seeing that. handleSubmit(mySubmitAction) returns a promise, where the catch handleSubmit(mySubmitAction)(event) throws an handleSubmit(...) is not If I change it to handleSubmit(event) I always get the success On 17 November 2015 at 04:14, Erik Rasmussen notifications@github.com
|
Will your use case be fixed by #276? |
No it's a different use case. Am I missing something that the catch function isn't called? Are you seeing On 17 November 2015 at 08:37, Erik Rasmussen notifications@github.com
|
Aha! This is a legit bug. |
There used to be an undocumented boolean flag you could pass to get this behavior, but I could find no reference to why that was not the default behavior. Fixed in |
Awesome the catch func is now being called, thanks so much for your One small thing the catch is being called with no params, it's fine as I On 17 November 2015 at 09:32, Erik Rasmussen notifications@github.com
|
I would expect that it would be rejected with whatever the |
@kristian-puccio #291 reminded me why the behavior was as it was. You will need to use the |
Great thanks @erikras. |
You guys might be interested in |
@erikras for Certainly I can use your code above to fix that: <form onSubmit={event =>
handleSubmit(mySubmitAction)(event) // <---- this is the promise returned from handleSubmit()
.then(() => {
// submission was successful
}, errors => {
// submission was unsuccessful
}))}>
// render inputs
</form> |
@kristian-puccio @erikras I'm using the asyncValidate option of redux-form? If that fails, error is shown but when it passes the validation, after that I'm unable to submit my form. Can you tell me what could be the reason behind that? Here is my aysnc validate method: import * as api from './tools/apiConfig'; function asyncValidate(values) { |
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. |
Is it possible to be notified when a form submit is made and didn't pass validation?
Maybe even just have the promise that handleSubmit returns call catch or resolve the promise with some errors.
I'd like to be able to do a couple of things with this, 1 is to track a hasSubmitted status about the form so I can show more intense errors if they have and 2 scroll to the first input with an error.
The text was updated successfully, but these errors were encountered: