Rails 5 - 使用item_wrapper_tag在simple_form中设置集合

问题描述:

在我的simple_form中,我有一个字段,其中包含作为一系列复选框的集合。它很长,占用了很多空间。Rails 5 - 使用item_wrapper_tag在simple_form中设置集合

我想使用CSS设置复选框的样式,以便将其限制在180像素高度并包含在可滚动框中。我在simple_form代码:

<th>Authors</th> 
    <td><%= f.association :authors, as: :check_boxes, item_wrapper_tag: :div, item_label_class: 'h_180', label: false, collection: Author.order('name ASC') %></td> 

我包裹在一个div轨输出与item_wrapper_tag: :div。我如何设计这个div? item_label_classitem_wrapper_class都不起作用。有

我在我的应用程序复选框的选择,但我实现它有所不同:

<%= f.collection_check_boxes(:item_ids, Item.all.sort_by { |x| x.name }, :id, :name) do |b| %> 
    <%= b.label class: "label-checkbox", style:"padding-right:5px" do > 
      <%= b.check_box + " " + b.text + " "%> 
    <% end %> 
<% end %> 

我想你可以再次风格的复选框的标签样式的方式:

<%= (b.check_box class: "checkbox-class", style: "checkbox-style") + " " + b.text + " "%> 

如果您选择以这种方式实施选择,请确保允许控制器接收:item_ids作为参数。