form with multiple submit buttons, clicked button is lost
See original GitHub issueWhen you add a ‘name’ attribute on a <button>, that name is submitted in the form data.
You can use this to detect which button is clicked if you have multiple submit buttons on a form.
Turbo seems to remove this, breaking this functionality.
<form name="myform">
<input type="email" name="myform[email]" />
<button type="submit" name="myform[prev]">Previous</button>
<button type="submit" name="myform[next]">Next</button>
</form>
On a normal browser submit, I see this as data submitted in the network-inspector (if I click the ‘next’ button):
myform%5Bemail%5D=test%40test.com&myform%5Bnext%5D=
But with Turbo active, I see this:
myform%5Bemail%5D=test%40test.com
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:17 (3 by maintainers)
Top Results From Across the Web
Two submit buttons in one form - Stack Overflow
Since a button's value is submitted only if clicked, you'd have to search the form values for these pre-defined names. I think the...
Read more >How to use multiple submit buttons in an HTML form
Create a button with type submit. This button will trigger the default action attribute of the form and send our input data to...
Read more >Multiple Submit Buttons - Apache Software Foundation
Often, we have multiple submit buttons within a single form. The below is just a simple way of identifying which button was clicked,...
Read more >Submit form with multiple buttons - Forums - Liferay Community
I have a form. I want two submit buttons. One which will submit the form completly. The other that will add version things...
Read more >Using Multiple Submit Buttons With A Single Form
Option 1 – Buttons With Same Name, Different Text ... This solution involves creating several input elements with the type being set to...
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 FreeTop 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
Top GitHub Comments
I’ve opened https://github.com/hotwired/turbo/pull/653 to attempt to resolve this issue.
Had the issue, Its not because of the multiple submit buttons, but because of the
button
itself. Changing this to an<input type="submit">
works better. BTW, the button works in the browser scenario, I think it is an issue and deserve to be fixed.