Forum: Ruby on Rails Multiple submit buttons

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.
15977b0a3b7e270bf3d1baaadfb79a59?d=identicon&s=25 Lantis Sephiro (lantis)
on 2006-04-08 02:45
Hi,

How do i differentiate different submits tags / buttons on one form. Say
I want to create an edit form and I want to provide two buttons; one to
save and one to cancel. I would have:
<%= submit_tag 'Ok' %>
<%= submit_tag 'Cancel' %>
How do I know which button get pressed by the user?

One more thing, how to specify the default selection in a select tag
(drop-down list)?

Thanks,

Lantis.
41e1579600683eed6c00af9a425268e6?d=identicon&s=25 Edward Frederick (Guest)
on 2006-04-08 03:16
(Received via mailing list)
Lantis,

Check @params[:commit].

Cheers,

Eddie

----------------------------------
epfrederick@gmail.com
edwardfrederick.com
30269682335f1fb247d71969fa715b5e?d=identicon&s=25 Roberto Saccon (rsaccon)
on 2006-04-08 03:22
(Received via mailing list)
Often links are used for cancel. It's simpler and links can be nested
inside
the form.

If you want to use buttons for non-remote forms, you just need to give
them
different name/id so your controller can distinguish them. If you want
to
use buttons in remote_forms, you need to hack something with  hidden
fields,
because prototype serializes only one submit button.
This topic is locked and can not be replied to.