I am trying to add a second submit button to a redux-form.
Both buttons should dispatch an action that saves the data but depending on the button pressed the user should be routed to different pages.
So I defined a handler that I pass as onSubmit
prop to the form.
But as far as I can see only the form data is passed to this handler:
The docs on handleSubmit
note:
A function meant to be passed to
<form onSubmit={handleSubmit}>
or to<button onClick={handleSubmit}>
. It will run validation, both sync and async, and, if the form is valid, it will callthis.props.onSubmit(data)
with the contents of the form data.
What I am missing is a way to also pass the information about the button pressed (e.g. the click event) to my onSubmit handler, so that i can save and route as intended.
isSaveMode = true
) and on the basis of this flag, I need to trigger validations on specific fields like so:<Field {...props} validate={isSaveMode && [validateRequiredText]}/>
– saran3h