question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

form with multiple submit buttons, clicked button is lost

See original GitHub issue

When 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
seanpdoylecommented, Jul 28, 2022

I’ve opened https://github.com/hotwired/turbo/pull/653 to attempt to resolve this issue.

1reaction
sukeicommented, May 25, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found