[英]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. 我想使用simple_form生成一个取消按钮....但不太确定如何做到这一点。
<%= 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? 我怎么做到的?
Should this be supported by simple form? 这应该用简单的形式支持吗? I had a quick look at github and did not find anything related. 我快速浏览了github并没有发现任何相关内容。
How about link_to "Cancel", :back
? link_to "Cancel", :back
怎么样link_to "Cancel", :back
?
You can do it with bootstrap easily. 你可以轻松地使用bootstrap。
<button type="submit" class="btn btn-default">Create Plan</button>
<%= link_to "Cancel", :back, {:class=>"btn btn-default"} %>
Using simple_form and erb: 使用simple_form和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. 这样做不会将您带到上一页,它会将表单重置为其初始状态。
Or since Rails 3: 或者自从Rails 3:
link_to "Cancel", @foo
where @foo
is your new or existing model object. 其中@foo
是您的新模型对象或现有模型对象。 Depending on which it is, this link takes you to either edit
or new
. 根据它的不同,此链接将带您进行edit
或new
。
您可以使用<%= button_tag "Cancel", :type => 'reset' %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.