Align checkboxes for f.collection_check_boxes with Simple_Form

前端 未结 4 2038
醉梦人生
醉梦人生 2020-12-16 18:08

I am using RoR and I am using the Simple_Form gem for my forms. I have an object relation whereby a User can have multiple Roles, and during creation, the admin can select

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 18:39

    According to the doc of collection_check_boxes, there is an option item_wrapper_class to give a css class to the span containing the checkbox. Use it like that

    <%= f.collection_check_boxes :role_ids, Role.all, :id, :name, :item_wrapper_class => 'checkbox_container' %>
    

    And a CSS style to keep the checkbox and the label on the same line:

    .checkbox_container input {
      display: inline;
    }
    

提交回复
热议问题