marcamillion
marcamillion

Reputation: 33755

How do I style the 'label' of each checkbox generated by Simple_Form?

This:

<%= f.input :accomplished_goal, label: "Accomplished goal this week?", collection: ["Yes", "No"], as: :check_boxes, label_html: { class: 'checkbox inline' } %>

Produces:

<div class="control-group check_boxes optional weekly_entry_accomplished_goal">
   <label class="check_boxes optional control-label checkbox inline">Accomplished goal this week?</label>
    <div class="controls">
       <label class="checkbox">
           <input class="check_boxes optional" id="weekly_entry_accomplished_goal_yes" name="weekly_entry[accomplished_goal][]" type="checkbox" value="Yes" />
             Yes
       </label>
       <label class="checkbox">
           <input class="check_boxes optional" id="weekly_entry_accomplished_goal_no" name="weekly_entry[accomplished_goal][]" type="checkbox" value="No" />
              No
       </label>
           <input name="weekly_entry[accomplished_goal][]" type="hidden" value="" />
    </div>
</div>

Ideally, I would like to add the style inline to the inner label class="checkbox"

How do I do that?

Upvotes: 1

Views: 957

Answers (1)

marcamillion
marcamillion

Reputation: 33755

This is what I found works:

<%= f.input :accomplished_goal, label: "Accomplished goal this week?", collection: ["Yes", "No"], as: :check_boxes, item_wrapper_class: 'inline' %>

i.e. using the attribute item_wrapper_class: 'inline'

Adds the class inline to the internal <label class="checkbox inline">

Upvotes: 1

Related Questions