Forum: Ruby on Rails Specify a controller action via attribute in INPUT tag?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-03-27 18:51
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
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-27 19:14
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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-03-27 19:19
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
C56f6508ce4610e8527606a435b5870f?d=identicon&s=25 William Lefevre (wlefevre)
on 2006-03-27 23:11
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
This topic is locked and can not be replied to.