# More than one submit\_tag in a single form

**URL:** <https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742>\
**Category:** Rails\
**Created:** [December 16, 2008, 8:44am UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742 "2008-12-16T08:44:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 16, 2008, 8:44am UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/1 "2008-12-16T08:44:32Z")

</div>

Hai everyone ,  
I have a list of users(each user in a row)and an Approve button for each  
user. I wish to change the status of the user to be approved when I  
click on the Approve button of a user. When I tried getting all the  
users in the params hash. I want to get the id of the user according to  
which “Approve” button I clicked. How can I implement this one?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 16, 2008, 9:03am UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/2 "2008-12-16T09:03:57Z")

</div>

First let me say that your question sounds stupid, because based on the  
info you’ve given us it would be simpler to use multiple forms. However,  
you need look no farther that the doc for submit\_tag.  
[http://api.rubyonrails.com/](http://api.rubyonrails.com/)

-K

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 16, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/3 "2008-12-16T15:01:07Z")

</div>

On Tuesday 16 December 2008 03:03 am, Keynan P. wrote:

> First let me say that your question sounds stupid, because based on  
> the  
> info you’ve given us it would be simpler to use multiple forms.  
> However,  
> you need look no farther that the doc for submit\_tag.  
> [http://api.rubyonrails.com/](http://api.rubyonrails.com/)

Replying offlist: Is there any good purpose served by using the word  
“stupid” which may lead the OP to infer that you are calling him  
stupid. (Yes, I know you didn’t say that.)

Randy K.

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 16, 2008, 8:19pm UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/4 "2008-12-16T20:19:21Z")

</div>

On Dec 16, 6:17 pm, Ellen B [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes, I can continue to muck with the CSS to get the link to exactly  
> match the SUBMIT button, but I wondered if it’s possible to have the  
> two SUBMIT buttons going to different actions and how to do it. I’m

Not really. Going to the same url pretty much means it will be the  
same action.  
You can get the button clicked as a parameter (if i remember correctly  
via params[:commit] for a normal submit thing, or you can use   
if you want the submitted parameter to be distinct from the label.

Fred

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 16, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/5 "2008-12-16T19:18:19Z")

</div>

(Woah there, I don’t think it sounds stupid. This is a pretty common  
sort of thing to want to do in HTML UIs - _without_ a separate form  
for each. If you don’t know RoR, you wouldn’t think to have a single  
form for each user listed on the page or whatever; that’s not the way  
a proficient web developer would approach the problem in conventional  
HTML. )

I’m having a similar problem. I’m modifying Redmine. In a form to  
create a new bug/issue, there is currently a SUBMIT button to create  
the issue and a link to preview the issue. I want the link to be a  
button, instead. Here’s the code:

\<% labelled\_tabular\_form\_for :issue, @issue,  
:html =\> {:multipart =\> true, :id =\>  
‘issue-form’} do |f| %\>  
\<%= error\_messages\_for ‘issue’ %\>

  
\<%= render :partial =\> ‘issues/form’, :locals =\> {:f =\> f} %\>  

 \<%= submit\_tag l(:button\_create), :class=\> 'but mb' %\> \<%= link\_to\_remote l(:label\_preview), { :url =\> { :controller =\> 'issues', :action =\> 'preview', :project\_id =\> @project }, :method =\> 'post', :update =\> 'preview', :with =\> "Form.serialize('issue-form')", :complete =\> "Element.scrollTo('preview')" }, :accesskey =\> accesskey(:preview), :class =\> 'but' %\> 
\<% end %\>

Yes, I can continue to muck with the CSS to get the link to exactly  
match the SUBMIT button, but I wondered if it’s possible to have the  
two SUBMIT buttons going to different actions and how to do it. I’m  
not a RoR developer; I’m a UI designer w/ a lot of HTMl/JS experience  
and I’m just trying to improve the usability of an existing (complex)  
RoR application and customize the look & feel for our site. Sadly,  
there’s no “RoR for UI Designers Cookbook”

Thanks for any help.

– EB

(The RoR documentation format is pretty weak, btw. No Search?  
Incidentally, when I google [submit\_tag ruby on rails] I get

> **[ActionView::Helpers::FormHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001394)**
>
> Form helpers are designed to make working with resources much easier compared to using vanilla HTML.

which doesn’t document submit\_tab. The RoR documentation site sucks –  
no search??

the documentation for submit\_tag is at  
[Peak Obsession](http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001537))

On Dec 16, 12:03 am, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 18, 2008, 5:04am UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/6 "2008-12-18T05:04:08Z")

</div>

Please, correct me if I am wrong, but couldn’t you just assign a value  
to each submit button that means what you need in your application  
(and ID value, for example) then check the value from the params hash?

Pepe

On Dec 16, 2:18 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [December 18, 2008, 5:07am UTC](https://www.ruby-forum.com/t/more-than-one-submit-tag-in-a-single-form/155742/7 "2008-12-18T05:07:39Z")

</div>

and then you could check the value of the submit button and send it to  
the right action:

if params[:commit] == “foo”  
foo  
else  
bar  
end
