Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate a cancel button in simple_form?

I want to generate a cancel button using simple_form....but not quite sure how to do that.

<%= f.button :submit, :class => "btn btn-warning btn-small", :label => "Save Changes" %>
<%= f.button :cancel, :class => "btn btn-inverse btn-small", :label => "Cancel" %>

But the cancel button doesn't work.

How do I get that?

like image 727
marcamillion Avatar asked Feb 28 '13 02:02

marcamillion


3 Answers

Should this be supported by simple form? I had a quick look at github and did not find anything related.

How about link_to "Cancel", :back ?

like image 113
doesterr Avatar answered Nov 01 '22 23:11

doesterr


You can do it with bootstrap easily.

<button type="submit" class="btn btn-default">Create Plan</button>
<%= link_to "Cancel", :back, {:class=>"btn btn-default"} %>
like image 45
hiveer Avatar answered Nov 02 '22 00:11

hiveer


Using simple_form and erb:

<%= f.submit, 'Save', class: 'btn btn-primary' %>
<%= f.button :button, 'Cancel', type: :reset, class: 'btn btn-none' %>

Doing this does not take you to the previous page, it resets the form to its initial state.

like image 4
dinjas Avatar answered Nov 02 '22 01:11

dinjas