Topic: Two buttons

I am struggling with controlling what module gets executed when a user presses a button. In HTML, I handle this with <form action=

Re: Two buttons

Your post was truncated, please try again. Thanks

Re: Two buttons

If I have two buttons on the same page, how do I know which one was pressed?

Re: Two buttons

Hello

Let say you have 2 submit buttons in your form one with an id of 'MyButton1' and another with an id of 'MyButton2', In your controller you can test which submit button has been clicked like that

def youractionname
  case params[:commit]
      when 'MyButton1' then
        do something
      when 'MyButton2' then
        do something else      
   end
end

Hope this helps
Cheers

Last edited by anso (2013-05-06 08:59:04)

Re: Two buttons

You can also look at 'button_to' method in ActionView::Helpers::UrlHelper