values and formiApi is undefined in onSubmit #1308
Answered
by
Hyperkid123
Nilesh9768
asked this question in
Need help
|
I'm trying to capture the form values with the click of submit button. But the What am I missing here? Hoping for a quick response. Thank you! |
Answered by
Hyperkid123
Aug 8, 2022
Replies: 1 comment 1 reply
|
@Nilesh9768 that is because you are calling the <form
onSubmit={(e) => {
handleSubmit(e);
}}
>
// or simply
<form onSubmit={handleSubmit}>You can follow the docs here: https://data-driven-forms.org/components/form-template#heading-minimalformtemplate The on Her is your code with working submit: https://codesandbox.io/s/hungry-http-kdyqv9?file=/src/App.js:1393-1571 |
1 reply
Answer selected by
Nilesh9768
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Nilesh9768 that is because you are calling the
onSubmitbut you are supposed to use thehandleSubmit. The form submit callback should look like thisYou can follow the docs here: https://data-driven-forms.org/components/form-template#heading-minimalformtemplate
The on
onSubmitis the actual unchanged onSubmit callback you pass to the renderer. And since you are not giving it any arguments, it does not has any in the callback.Her is your code with working submit: https://codesandbox.io/s/hungry-http-kdyqv9?file=/src/App.js:1393-1571