handleSubmit custom params #2535
-
If I have a form which has two buttons to submit, one of them is to save the progress and the other is to finish the form. How can I submit with my own logic for each of the actions in the Formik The idea is that each button passes or is assigned a meta data to identify the type of click that the user made to apply the logic that corresponds to each submit. But how is this done in practice? I had thought to props return (
<Formik
onSubmit={(values, formikProps, customProps) => {
console.log(customProps) // should print partial or finish
}}
>
{(handleSubmit) => (
<input type='text' ... />
<button onClick={handleSubmit('partial')}>Save Progress</button>
<button onClick={handleSubmit('finish')}>Finish</button>
}
<Formik>
)
``` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
A sample solution here (link to codesandbox) I had followed this (link to formik docs) when I had a similar use case at work. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
I had a similar case where the form had 2 submit buttons with different effects. I ended up making a |
Beta Was this translation helpful? Give feedback.
@vicasas
A sample solution here (link to codesandbox)
I had followed this (link to formik docs) when I had a similar use case at work.
I hope this helps!