3

这是我想要的输出:

<button type="submit" class="btn btn-large btn-search btn-primary">
  <i class="icon icon-search"></i> Find Your Apartment
</button>

如果我为链接而不是按钮执行此操作,我可能会执行以下操作:

<%= link_to root_path do %>
  <i class="icon icon-search"></i> Find Your Apartment
<% end %>

但鉴于我使用的是 Rails 表单助手,我不太确定如何使用f.submit.

我试过了:

<%= f.submit, :class => "btn btn-large btn-search btn-primary" do %>
  <i class="icon icon-search"></i> Find Your Apartment
<% end %>

这给了我一个语法错误。

想法?

编辑1:

对于它的价值,这不会给我语法错误,但不会呈现图标或“查找您的公寓”文本:

<%= f.submit "Find Your Apartment", :class => "btn btn-large btn-search btn-primary" do %>
  <i class="icon icon-search"></i> Find Your Apartment
<% end %>
4

1 回答 1

10

你可以使用按钮标签

<%= button_tag(type: 'submit', class: "btn btn-large btn-search btn-primary") do %>
 <i class="icon icon-search"></i> Find Your Apartment
<% end %>
于 2013-02-10T10:17:39.433 回答