如何将 sr-only class 添加到输入的标签?
How to add sr-only class to input's label?
我有简单的表格:
<%= 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>
如何将 'sr-only' class 添加到标签元素?
就这样:
<%= f.input :url, placeholder: "http://...", label_html: { class: 'sr-only' } %>
我有简单的表格:
<%= 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>
如何将 'sr-only' class 添加到标签元素?
就这样:
<%= f.input :url, placeholder: "http://...", label_html: { class: 'sr-only' } %>