Access form `onSubmit` event data?
See original GitHub issueQuestion?
I’m using withFormik
and I currently have 2 separate submit buttons in my form, and I need to identify which one has been clicked in my handleSubmit
function, but event
data isn’t passed along. Any ideas how I could do that?
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Get form data in ReactJS - Stack Overflow
There are a few ways to do this: 1) Get values from array of form elements by index handleSubmit = (event) => {...
Read more >3 Ways to Get Form Data onSubmit in React - Designcise
We can access a form control element by its (zero-based) index in the form, in the following way: const handleSubmit = (event) => ......
Read more >HTMLFormElement: submit event - Web APIs | MDN
The submit event fires when the user clicks a submit button ( <button> or <input type="submit">) or presses Enter while editing a field...
Read more >How to Get the Value of a Form Input on Submit in React
Set an onSubmit event handler on the form element. Access the value of the input field in the onSubmit event handler. For example:....
Read more >onsubmit Event - W3Schools
The onsubmit event occurs when a form is submitted. Browser Support. Event. onsubmit, Yes, Yes, Yes, Yes, Yes ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why not pass event object as a third argument to
onSubmit
(handleSubmit
)?Let me give an example: There is non-standard feature in Chrome, called “Credentials API”, which allows developer to save and use passwords to/from browser. One of constructors for
PasswordCredential
(docs) accepts HTMLFormElement. So I need to pass HTML form to it, in case authorisation was successful and I want to save credentials. So how am I supposed to write my own handler, if I need HTML form inside submitForm, to pass it to my API/service call/action?I can make PR for that
Not edge case. Many developers have complex forms with multiple submits. I was hoping I could use Formik to simplify the forms in my application, but I don’t have much confidence at this point. The fact that the owner dismisses good ideas with terse comments such as “You can make your own handler…” is not helping the situation.