Style Rails collection_check_boxes

后端 未结 2 493
旧时难觅i
旧时难觅i 2021-02-04 11:40

I been trying to apply some CSS classes to collection_check_boxes but I can\'t get it to work. Right now I doing this:

<
相关标签:
2条回答
  • 2021-02-04 11:48

    Try it like this:

        <%= f.collection_check_boxes(:brand_ids, Brand.all, :id, :name) do |b| %>
            <%= b.label class:"label-checkbox" do%>
             <%=b.check_box + b.text%>
            <%end%>
        <% end %>
    
    0 讨论(0)
  • 2021-02-04 12:14

    A little shorter to use an inline block

    <%= f.collection_check_boxes(:brand_ids, Brand.all, :id, :name) do |b| %>
      <%= b.label(class:"label-checkbox") { b.check_box + b.text } %>
    <% end %>
    
    0 讨论(0)
提交回复
热议问题