If you want to use image as submit tag you need to do it this way:
<%= image_submit_tag("/images/a.gif", { :name =>
"commit", :value => "A" } ) %>
<%= image_submit_tag("/images/b.gif", { :name =>
"commit", :value => "B" } ) %>
However, this doesn''t work in MS Explorer. Explorer doesnt return the
variable commit as a parameter but only the 2 variable commit.x and
commit.y that give you the coordinate of the mouse when the user
clicked on the picture, this is useless because you still can tell if
the user clicked on A or B.
You need to do it this way if you want this to work with any browser:
View:
<%= form_tag( :action => "multiple_image_submit" ) %>
<%= image_submit_tag("/images/a.gif", { :name => "A" }
) %>
<%= image_submit_tag("/images/b.gif", { :name => "B" }
) %>
<%= end_form_tag() %>
Controller:
def multiple_image_submit
if params[''A.x''] == "Click A"
render :text => "Clicked on A"
else
render :text => "Clicked on B"
end
end
On 19/05/06, Gael Pourriel <gael.pourriel@gmail.com>
wrote:> You can, just use the variable called params[:commit] in the controller
>
> View:
>
> <%= form_tag( :action => "multiple_submit" ) %>
> <%= submit_tag( "Click A") %>
> <%= submit_tag( "Click B") %>
> <%= end_form_tag() %>
>
> Controller:
>
> def multiple_submit
> if params[:commit] == "Click A"
> render :text => "Clicked on A"
> else
> render :text => "Clicked on B"
> end
> end
>
> On 19/05/06, jose <jose@stat.ucla.edu> wrote:
> > is it by design? is it standard? how do you give users multiple
> > actions on a form?
> >
> > --
> > Posted via http://www.ruby-forum.com/.
> > _______________________________________________
> > Rails mailing list
> > Rails@lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
>