Wes Gamble
2006-Mar-27 16:53 UTC
[Rails] Specify a controller action via attribute in INPUT tag?
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 <INPUT> 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 -- Posted via http://www.ruby-forum.com/.
Ivan Medda
2006-Mar-27 17:14 UTC
[Rails] Re: Specify a controller action via attribute in INPUT tag?
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 Gamble 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 <INPUT> 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-- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Mar-27 17:19 UTC
[Rails] Re: Specify a controller action via attribute in INPUT tag?
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 Medda 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 Gamble 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 <INPUT> 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-- Posted via http://www.ruby-forum.com/.
William LeFevre
2006-Mar-27 21:12 UTC
[Rails] Re: Specify a controller action via attribute in INPUT tag?
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 Gamble 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 Medda 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 Gamble 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 <INPUT> 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-- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- Can''t call public application.rb method from ERb template
- Using <%= text_field %> within partials is problematic
- Are form_remote_tag and submit_to_remote mutually exclusive?
- Example using Builder::XmlMarkup and .rxml files?
- Newbie: Can''t get file to upload