Re: Multiple Submit Buttons in One Form

Hunter Hillegas
Sat, 16 Jul 2005 23:16:41 -0000

Thanks.

The problem is that all the buttons need to show the word
''Delete'' when
rendered in the browser.

They cannot be unique.

Any other suggestions?

> From: Dominic Marks
<dom-oCiW/wK895g3fM+T6T0RSip2UmYkHbXO@public.gmane.org>
> Date: Sun, 17 Jul 2005 00:09:44 +0100
> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org>
> Cc: Hunter Hillegas
<lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org>
> Subject: Re: [Rails] Multiple Submit Buttons in One Form
>
> 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