如何用 css、字形和符号格式化 f.submit?
How to format f.submit with css, glyphicons, and symbol?
我们如何做到这一点:<%= f.submit :conceal %>
使用 <span class="glyphicon glyphicon-plus">
、单词 Private
和 class: "btn"
。
这里有一些尝试:
#This didn't make :conceal work
<%= button_tag(type: 'submit', class: "btn") do %>
<% :conceal %><span class="glyphicon glyphicon-plus"></span> Private
<% end %>
#This stopped :conceal from working too
<%= f.submit "Private", class: "btn" do %>
<% :conceal %>
<% end %>
#This ignored the 2nd line despite, do
<%= f.submit :conceal, class: "btn" do %>
<span class="glyphicon glyphicon-plus"></span> Private
<% end %>
在控制器中:
if (params[:commit] == 'conceal')
@valuation.conceal = true
end
试试这个
<%= f.submit :conceal, class: 'btn', autofocus: true %>
raw('<span class="glyphicon glyphicon-plus">"Private"</span>')
<% end %>
试试这个
<%= f.button :submit, name: "conceal", value: "1" do %>
<i class="glyphicon glyphicon-plus">private</i>
<% end %>
在您的控制器中,您将获得值为“1”的参数[:conceal]。
也许在语言环境文件上设置跨度应该可行,例如:
en:
helpers:
submit:
your_model_name:
create: "<span class='glyphicon glyphicon-plus'></span> Private"
使用input[type=submit]
恐怕无法实现带图标的按钮外观。
你必须选择 button
。请考虑以下内容:
<%= button_tag(type: "submit", class: "btn", name: "commit", value: "conceal") do %>
<span class="glyphicon glyphicon-plus"></span> Private
<% end %>
生成 HTML 类似于:
<button name="commit" type="submit" class="btn" value="conceal">
<span class="glyphicon glyphicon-plus"></span> Private
</button>
希望对您有所帮助!
我们如何做到这一点:<%= f.submit :conceal %>
使用 <span class="glyphicon glyphicon-plus">
、单词 Private
和 class: "btn"
。
这里有一些尝试:
#This didn't make :conceal work
<%= button_tag(type: 'submit', class: "btn") do %>
<% :conceal %><span class="glyphicon glyphicon-plus"></span> Private
<% end %>
#This stopped :conceal from working too
<%= f.submit "Private", class: "btn" do %>
<% :conceal %>
<% end %>
#This ignored the 2nd line despite, do
<%= f.submit :conceal, class: "btn" do %>
<span class="glyphicon glyphicon-plus"></span> Private
<% end %>
在控制器中:
if (params[:commit] == 'conceal')
@valuation.conceal = true
end
试试这个
<%= f.submit :conceal, class: 'btn', autofocus: true %>
raw('<span class="glyphicon glyphicon-plus">"Private"</span>')
<% end %>
试试这个
<%= f.button :submit, name: "conceal", value: "1" do %>
<i class="glyphicon glyphicon-plus">private</i>
<% end %>
在您的控制器中,您将获得值为“1”的参数[:conceal]。
也许在语言环境文件上设置跨度应该可行,例如:
en:
helpers:
submit:
your_model_name:
create: "<span class='glyphicon glyphicon-plus'></span> Private"
使用input[type=submit]
恐怕无法实现带图标的按钮外观。
你必须选择 button
。请考虑以下内容:
<%= button_tag(type: "submit", class: "btn", name: "commit", value: "conceal") do %>
<span class="glyphicon glyphicon-plus"></span> Private
<% end %>
生成 HTML 类似于:
<button name="commit" type="submit" class="btn" value="conceal">
<span class="glyphicon glyphicon-plus"></span> Private
</button>
希望对您有所帮助!