-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Multiple buttons #33
Comments
Sure! Do you want to work on a patch? |
Yes, of course. It should be just as simple as to replace : |
We'll need to expose the submit, change and error handlers so children can leverage them as well. |
I use onClick handlers on children buttons (and I need to save formData on my parent component's state to be able to pass it to these handlers). It's mostly because I don't know if it is possible to know which submit button was clicked in the handleSubmit handler... |
I don't get it, so how do you get form validation? |
In my use case, the form validation is made on the server side and for some buttons (e.g. a Cancel button), we don't want form validation). I agree it is an exception and we need to be able to validate the form in each button. What do you mean by
? |
I'm just realizing that adding a button type=submit is enough to trigger the form submission, which triggers the validation anyway. So yeah, just being able to pass a submit button as a children is enough. Nice. Could you take care of working on a patch? |
The problem is that form validation happens after the click event on the button. Then I tried to set some flag in the state of my parent component and to use this flag in the onSubmit handler but when I do this, the values in my fields "dissapears" and so the validation fails. It's strange that setting the state on my parent component can have an effect on the fields... So maybe it's not a good idea to have multiple submit buttons. I can work on the patch though. It will be useful to allow users to use their own markup for buttons instead of the default submit button. |
Fixed by #34 |
I was not able to make the above solution work, |
@bhunwal please see the "Validate and submit form from external control" example in tips and tricks |
It would be great to be able to use multiple buttons in the form. Maybe we could pass them via children ?
The text was updated successfully, but these errors were encountered: