如何在标签标签中添加文字simple_form

时间:2015-05-17 14:34:33

标签: ruby-on-rails simple-form

我正在使用simple_form并尝试在结束标签标签之前添加文字。

<label>search</label>

这就是我所拥有的

<%= simple_form_for "", html: { id: "searchform1", class: "searchform", role: "search" }, :method => :get do |f| %>

<%= f.input "", wrapper: false, label_html: { id: "spanLabel0", class: "fLabel"}, input_html: {size: 27, name: "s", id: "s1", class: "s", title: "search"} %>

<%= f.submit "search", :type => :image, :src => "/assets/search.png", id: "searchsubmit1", class: "searchsubmit" %>

<% end %>

我希望重现这一点(在关闭标签标签之前注意“搜索”):

<form accept-charset="UTF-8" action="/" class="simple_form searchform" id="searchform1" method="get" role="search">

<label class="string required control-label fLabel" for="s1" id="spanLabel0">search</label>

<input class="string required s" id="s1" name="s" size="27" title="search" type="text">

<input class="searchsubmit" id="searchsubmit1" name="commit" src="/assets/search.png" type="image" value="search">

</form>

1 个答案:

答案 0 :(得分:1)

如果您想要一个标记为搜索表单,只需将<%= f.label :search %>:放在f.input标记之前。您可以在Action View form Helper文档

中找到有关该信息的更多信息