如何在simple_form中生成取消按钮?

时间:2021-08-12 15:57:55

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?

我怎么做到的?

5 个解决方案

#1


14  

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“取消”怎么样,:回来?

#2


4  

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"} %>

#3


2  

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.

执行此操作不会将您带到上一页,它会将表单重置为其初始状态。

#4


0  

Or since Rails 3:

或者自从Rails 3:

link_to "Cancel", @foo

where @foo is your new or existing model object. Depending on which it is, this link takes you to either edit or new.

其中@foo是您的新模型对象或现有模型对象。根据它的不同,此链接将带您进行编辑或新建。

#5


0  

You can use as <%= button_tag "Cancel", :type => 'reset' %>

您可以使用<%= button_tag“取消”,:type =>'reset'%>

#1


14  

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“取消”怎么样,:回来?

#2


4  

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"} %>

#3


2  

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.

执行此操作不会将您带到上一页,它会将表单重置为其初始状态。

#4


0  

Or since Rails 3:

或者自从Rails 3:

link_to "Cancel", @foo

where @foo is your new or existing model object. Depending on which it is, this link takes you to either edit or new.

其中@foo是您的新模型对象或现有模型对象。根据它的不同,此链接将带您进行编辑或新建。

#5


0  

You can use as <%= button_tag "Cancel", :type => 'reset' %>

您可以使用<%= button_tag“取消”,:type =>'reset'%>