turbo: form with multiple submit buttons, clicked button is lost

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted 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.