Multiple submit buttons for one form

Hello gents,

I'm building an enterprise web-site which contains: 1) a table with editable fields (checkboxes, textboxes, etc.) 2) multiple "buttons" which represent actions.

How can I redirect from a particular button to a particualar action and get the values of all the controls on the form?

I know that ASP.NET and Java create wrappers for the buttons and save the state of the controls in a hidden filed ViewState. Is there any way in RoR to do the same?

Thanks in advance,   Dmitry

Nop Nop wrote:

Hello gents,

I'm building an enterprise web-site which contains: 1) a table with editable fields (checkboxes, textboxes, etc.) 2) multiple "buttons" which represent actions.

How can I redirect from a particular button to a particualar action and get the values of all the controls on the form?

I know that ASP.NET and Java create wrappers for the buttons and save the state of the controls in a hidden filed ViewState. Is there any way in RoR to do the same?

Thanks in advance,   Dmitry   

One way to do this would be to have 1 form and 1 action with a bunch of submit buttons.

Rails helpers names submit buttons "commit" so in your controller you could switch on params[:commit] and call an appropriate method for your "action".

-rm

face wrote:

Nop Nop wrote:

the state of the controls in a hidden filed ViewState. Is there any way in RoR to do the same?

Thanks in advance,   Dmitry   

One way to do this would be to have 1 form and 1 action with a bunch of submit buttons.

Rails helpers names submit buttons "commit" so in your controller you could switch on params[:commit] and call an appropriate method for your "action".

-rm

-- http://myutil.com/

Could you please give an example on how to define such a submit button? Actually I need not a button but an image which submits the form following the onclick event.

Nop Nop

Google is your friend.

  > 2) multiple "buttons" which represent actions.   > ..   > How can I redirect from a particular button to a particualar action and

Look at    "Multibutton Form"    #38 Multibutton Form - RailsCasts

All buttons will call the same action, but you'll have a means to identify the pressed button.

remark: it won't work with AJAX request. In this case, use a hidden field and sets its value differently in each submit button "onclick".

Alain Ravet