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. -- Posted via http://www.ruby-forum.com/.
Lantis, Check @params[:commit]. Cheers, Eddie ---------------------------------- epfrederick@gmail.com edwardfrederick.com On 4/7/06, Lantis Sephiro <semutluthu@yahoo.com> wrote:> 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. > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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. On 4/7/06, Lantis Sephiro <semutluthu@yahoo.com> wrote:> > 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? >-- Roberto Saccon - http://rsaccon.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060408/d60176bc/attachment.html