This project is archived and is in readonly mode.

#6001 ✓resolved

Remote forms with multiple submit controls don't report which submit was used, under Unobtrusive JavaScript

Reported by Chowlett | November 18th, 2010 @ 11:51 AM

(Rails 3.0.0)

Consider a simple view:

<%= form_tag({:action => 'debug'}) do %>
  <%= submit_tag "Foo" %>
  <%= submit_tag "Bar" %>
<% end %>

When this is submitted (by normal POST), the parameters includes "commit" => "Foo" or "commit" => "Bar".

However, if the form is using unobtrusive javascript to make it an AJAX request:

<%= form_tag({:action => 'debug'}, {:remote => true}) do %>
  <%= submit_tag "Foo" %>
  <%= submit_tag "Bar" %>
<% end %>

... then the parameters do not carry the submit control which was used. This is because the function callRemote in rails.js uses serializeArray on the form; but serializeArray doesn't take account of the control used to submit the form.

I have patched my local app by making use of originalEvent, but I have no means of using Git (my corporate firewall blocks the SSH port). How can I get my patch considered?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>