On Oct 15, 3:17 pm, "Ramón Castro"
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> You can send a parameter in a image_submit_tag?
>
> I have two buttons on a form and I do not know how to differentiate
> which has been pressed.
>
> <=% Image_submit_tag ("../ images / incluir.gif ": op
=>" addImage ")%>
> <=% Image_submit_tag ("../ images / eliminar.gif ": op
=>" delImage ")%>
>
Ramon -- I just had a similar case with submit_tag (which creates a
submit button and calls the action associated with the form). I
solved the problem by adding a :name parameter as one of the optional
parameters, then testing for in in the submit action associated with
the form. (I am not sure if :name is special, I was just copying an
example I found :-). , for example
<=% Image_submit_tag ("../ images / eliminar.gif ", :name =>
"del_image") %>
then in the controller, if your form action was called "manage_image",
you can test for the presence of the specific name value in the params
hash, like so:
def manage_image
if params[''del_image''] ##
... code to delete the image ...
else
... code to add the image ..
end
end
Here''s the link I found with a more complete description of the
solution:
http://www.railsdiary.com/diary/two_submit_buttons
Tom
I wish I had the
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---