How to provide 2 actions to a form?

Hi,
I have a form in rhtml. Now I have 2 buttons indside that form. Clicking
on the first button action will be ‘create’ & on second button action
will be ‘delete’. How to do this?
Thanx
Prash

On 3/14/06, Prashant T. [email protected] wrote:

I have a form in rhtml. Now I have 2 buttons indside that form. Clicking
on the first button action will be ‘create’ & on second button action will
be ‘delete’. How to do this?

Probably the easiest way is to give up on the ‘delete’ action being a
button, and just making it a link. (You could use images or CSS to style
the
link and the button very similarly.)

Don’t know much about RoR, but it’s pretty simple actually !

if post->b1 =“submit”
execute->action1
elseif post->b2 =“submit”
execute->action2

Josh on Rails wrote:

On 3/14/06, Prashant T. [email protected] wrote:

I have a form in rhtml. Now I have 2 buttons indside that form. Clicking
on the first button action will be ‘create’ & on second button action will
be ‘delete’. How to do this?

Probably the easiest way is to give up on the ‘delete’ action being a
button, and just making it a link. (You could use images or CSS to style
the
link and the button very similarly.)

stupid me
sorry… just tired I guess

if submit = v1


OKAY, just to be a nice guy

template
<%= form_tag(:action => “action2”)%>
<%= submit_tag ‘Edit’, :name => ‘_edit_button’ %>
<%= submit_tag ‘Delete’, :name => ‘_delete_button’ %>
<%= end_form_tag %>

controller
def action2
render_text params[:_update_button]
end

I hope it’s pretty self explainatory !!!

Alex Copot wrote:

stupid me
sorry… just tired I guess

if submit = v1


OKAY - I’m an idiot for today

template
<%= form_tag(:action => “action2”)%>
<%= submit_tag ‘Edit’, :name => ‘_button’ %>
<%= submit_tag ‘Delete’, :name => ‘_button’ %>
<%= end_form_tag %>

controller
def action2
render_text params[:_button]
end