如何设置Simple_Form生成的每个复选框的“标签”?

时间:2013-03-10 18:33:48

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

此:

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

产地:

<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>

理想情况下,我想将样式inline添加到内部label class="checkbox"

我该怎么做?

1 个答案:

答案 0 :(得分:1)

这是我发现的作品:

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

即。使用属性item_wrapper_class: 'inline'

将课程inline添加到内部<label class="checkbox inline">