Jamal Abdul Nasir
Jamal Abdul Nasir

Reputation: 2667

multi submit form

How will i have a form having more than one submit buttons..? And how will i know in the controller's action that which submit button is clicked..?

Upvotes: 0

Views: 125

Answers (1)

Daniel O'Hara
Daniel O'Hara

Reputation: 13438

You can set various values of your submit buttons, so you will know which one was submitted. Like this:

<input type="submit" name="submit_btn" value="First submit" />
<input type="submit" name="submit_btn" value="Second submit" />

After that, check on the server-side when submit_btn equals "First submit" or "Second submit":

if params["submit_btn"] == "First submit"
    #Actions
else
    #Other actions
end

Upvotes: 1

Related Questions