Re: Multiple Submit Buttons in One Form

Dominic Marks
Sat, 16 Jul 2005 23:09:44 -0000

On Saturday 16 July 2005 23:53, Hunter Hillegas wrote:
> ** Sorry, I let the last one go early! **
>
> In transitioning a WebObjects app to Rails, I''ve run into this
> question:
>
> How do I use multiple submit buttons in a single form?
>
> I have a list of items that are in the database. Each list item has a
> ''Delete'' button that looks like this:
>
> <a class="rec"
href="/admin/user_admin/edit/4"> <input
> class="del" name="4" type="submit"
value="Delete" />
>
> How can I have my destroy method pick up the right item?

Give all the buttons the same name, then check its value in your
action.

 <%= submit_tag ''One'', :name =>
''mybutton'' %>
 <%= submit_tag ''Two'', :name =>
''mybutton'' %>

In your action @params[''mybutton''] will equal One or Two.

> Anyone done this?
>
> Cheers,
> Hunter
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

--
Dominic Marks