Multiple images_submit_tag *all* "names" are given as parameters

I have a form like so:

<% form_remote_tag(:url => { :action => :foo}, :complete =>
“do_some_cool_ajax(request);”) do %>
<%= text_field_tag :myInput, params[:myInput], :size => 80 %>

<%= submit_tag "do function 1", :name => "f1"%>

<%= submit_tag "do funciton 2", :name => "f2"%>

<%= image_submit_tag("function3.png", :name => "f3")%> <%= image_submit_tag("function4.png", :name => "f4")%> <%= image_submit_tag("function5.png", :name => "f5")%> <%= image_submit_tag("function6.png", :name => "f6")%>
<% end %>

I would hope to get parameters that have only one of the names so that
I can test like so

if params[“f1”]

do some f1 stuff

else if params[“f2”]

do some f2 stuff


For this to work I need something like this in params:

Example 1: Parameters: {“f1”=>"", “action”=>“foo”,
“controller”=>“bar”, “myInput”=>“foobar”}

However I’m getting

Example 2: Parameters: {“f1”=>"", “f2”=>"", “f3”=>"", “f4”=>"",
“f5”=>"", “f6”=>"", “action”=>“foo”, “controller”=>“bar”,

Any ideas on how to isolate each of these actions so that I know which
submit was actually sent? Google searching lists a buch of sites that
say Example 1 should work.

I’ve tested on osx both firefox and safari and I get the same results.

For reference. It turns out that the Prototype library is not
designed to handle multiple submits of this type in an Ajax form. It
is a limitation that may be addressed in the future. In the meantime
it appears that the best answer is to create a hidden field, and fill
it with a value when a image is clicked.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs