Ruby-on-rails submit_tag rails 表单中的引导程序图标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14999294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:26:59  来源:igfitidea点击:

bootstrap icon in a submit_tag rails form

ruby-on-railsformstwitter-bootstrap

提问by Fran Martinez

I have this form:

我有这个表格:

<%= form_tag(user_pages_path(current_user), :method => "get") do %>
  <%= text_field_tag :update, 'yes', type: "hidden"  %>
  <%= submit_tag "Update list", :class => "btn btn-default" %>
<% end %>

and I would like to include an icon in the button. I'm using bootstrap, so i must include this code:

我想在按钮中包含一个图标。我正在使用引导程序,所以我必须包含以下代码:

<i class=" icon-repeat"></i>

?Any idea about how to include this code in the form button?

?知道如何在表单按钮中包含此代码吗?

回答by gabrielhilal

You can use button_taginstead of submit_tag:

您可以使用button_tag代替submit_tag

<%= button_tag(type: "submit", class: "btn btn-default") do %>
    Update list <i class="icon-repeat"></i>
<% end %>