# Specify a controller action via attribute in INPUT tag?

**URL:** <https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800>\
**Category:** Rails\
**Created:** [March 27, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800 "2006-03-27T18:51:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 27, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800/1 "2006-03-27T18:51:55Z")

</div>

I have a pre-existing form with one existing “SUBMIT” tag generated by  
\<%= submit\_tag %\>

I would like to add another \<INPUT type=“submit” …\> to my form.

How do I successfully associate that tag with a different  
controller action than the default one specified by my \<%=  
start\_form\_tag %\>?

Or does this approach even make sense?

In RoR, is it implied that an entire form is bound to a controller  
action?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 27, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800/2 "2006-03-27T19:14:45Z")

</div>

Hi,  
In the controller you must create an action that put in input your  
submits; you must control the “@params[:commit]” value to understand  
what is the button pushed. Once that you understand it, you must  
redirect the control to the right action with:

action\_name  
render :action=\> ‘action\_name’

Wes G. wrote:

> I have a pre-existing form with one existing “SUBMIT” tag generated by  
> \<%= submit\_tag %\>
> 
> I would like to add another \<INPUT type=“submit” …\> to my form.
> 
> How do I successfully associate that tag with a different  
> controller action than the default one specified by my \<%=  
> start\_form\_tag %\>?
> 
> Or does this approach even make sense?
> 
> In RoR, is it implied that an entire form is bound to a controller  
> action?
> 
> Thanks,  
> Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 27, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800/3 "2006-03-27T19:19:41Z")

</div>

OK, so basically if I want one form that “maps” to multiple actions then  
I have to have my form post to a “mini-controller” that figures out  
which action to call?

Wes

Ivan M. wrote:

> Hi,  
> In the controller you must create an action that put in input your  
> submits; you must control the “@params[:commit]” value to understand  
> what is the button pushed. Once that you understand it, you must  
> redirect the control to the right action with:
> 
> action\_name  
> render :action=\> ‘action\_name’
> 
> Wes G. wrote:
> 
> > I have a pre-existing form with one existing “SUBMIT” tag generated by  
> > \<%= submit\_tag %\>
> > 
> > I would like to add another \<INPUT type=“submit” …\> to my form.
> > 
> > How do I successfully associate that tag with a different  
> > controller action than the default one specified by my \<%=  
> > start\_form\_tag %\>?
> > 
> > Or does this approach even make sense?
> > 
> > In RoR, is it implied that an entire form is bound to a controller  
> > action?
> > 
> > Thanks,  
> > Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [March 27, 2006, 11:11pm UTC](https://www.ruby-forum.com/t/specify-a-controller-action-via-attribute-in-input-tag/87800/4 "2006-03-27T23:11:51Z")

</div>

I would think a min controller would only be necessary if you had a lot  
of different actions you wanted carried out from your form.

For example, I have a form with ‘Save’ and ‘Save and go to next’  
buttons. My save action updates the record and then based on the value  
of @params[:commit] either redisplays the same page or re-directs to the  
edit form for the next record.

William

Wes G. wrote:

> OK, so basically if I want one form that “maps” to multiple actions then  
> I have to have my form post to a “mini-controller” that figures out  
> which action to call?
> 
> Wes
> 
> Ivan M. wrote:
> 
> > Hi,  
> > In the controller you must create an action that put in input your  
> > submits; you must control the “@params[:commit]” value to understand  
> > what is the button pushed. Once that you understand it, you must  
> > redirect the control to the right action with:
> > 
> > action\_name  
> > render :action=\> ‘action\_name’
> > 
> > Wes G. wrote:
> > 
> > > I have a pre-existing form with one existing “SUBMIT” tag generated by  
> > > \<%= submit\_tag %\>
> > > 
> > > I would like to add another \<INPUT type=“submit” …\> to my form.
> > > 
> > > How do I successfully associate that tag with a different  
> > > controller action than the default one specified by my \<%=  
> > > start\_form\_tag %\>?
> > > 
> > > Or does this approach even make sense?
> > > 
> > > In RoR, is it implied that an entire form is bound to a controller  
> > > action?
> > > 
> > > Thanks,  
> > > Wes
