如何在输入标签中添加仅限sr的类?

时间:2015-03-10 13:01:43

标签: ruby-on-rails twitter-bootstrap-3 simple-form

我的形式很简单:

<%= simple_form_for @link do |f| %>
  <%= f.input :url, placeholder: "http://..." %>
  <%= f.button :submit, "Submit Link", class: "btn-primary" %>
<% end %>

输出如下输入:

<div class="form-group url required link_url">
  <label class="url required control-label" for="link_url">
    <abbr title="required">*</abbr> Url
  </label>
  <input class="string url required form-control" placeholder="http://..." type="url" name="link[url]" id="link_url">
</div>

我如何添加&#39; sr-only&#39; class to label element?

1 个答案:

答案 0 :(得分:2)

只是做:

<%= f.input :url, placeholder: "http://...", label_html: { class: 'sr-only' } %>