Simple form with two or more submit buttons

804 views
Skip to first unread message

Bharat

unread,
Sep 12, 2011, 4:42:53 PM9/12/11
to SimpleForm
This may be a Rails related question, but:
1. Is it possible to have two more submit buttons in Simple Form?
2. If yes, then can someone provide a short example?
Thanks in advance.
Bharat

Carlos Antonio

unread,
Sep 12, 2011, 4:53:02 PM9/12/11
to plataformate...@googlegroups.com
Yes, you can have as many submit buttons as you want to.

    <%= f.button :submit, "Send", :name => "send" %>
    <%= f.button :submit, "Do another thing", :name => "do_another_thing" %>
    <%= f.button :submit, "Do some other thing", :name => "do_some_other_thing" %>

It's pretty much the same way as Rails:

    <%= f.submit, "Send", :name => "send" %> 
    <%= f.submit, "Do another thing", :name => "do_another_thing" %>

You have to name the buttons because the action (unless it's html5) will be the same, so you need to know which button was pressed in your controller.

-- 
At.
Carlos Antonio

Bharat

unread,
Sep 13, 2011, 7:00:50 AM9/13/11
to SimpleForm
Thanks Carlos.
Bharat
Reply all
Reply to author
Forward
0 new messages