我怎样才能简单的表格,在标贴标签不换check_box

问题描述:

我怎样才能简单的表格,在标贴标签我怎样才能简单的表格,在标贴标签不换check_box

<%= simple_nested_form_for @project, 
          url: project_path(@project), 
          html: { 
           id: "project-form", 
           class: "form", 
          } do |f| %> 

    <%= f.association :tasks, 
        collection: Task.options_for_select, 
        as: :check_boxes, 
        required: false %> 

    <%= f.input :hold %> 


    <% end %> 

当前结果

<label for="task_ids_8"> 
    <input class="check_boxes optional" type="checkbox" value="8" name="task_ids" id="task_ids_8">Structure</label> 

期望的结果不换check_box

<label for="task_ids_8">Structure</label> 
<input class="check_boxes optional" type="checkbox" value="8" name="task_ids" id="task_ids_8"> 

我需要知道如何为个人“保持”输入和收集做到这一点。

+0

你试过:''或''的[参考]( http://stackoverflow.com/a/18913719/3366016)更新的导轨。 – user3366016

+0

我有。对于个人输入,我将不得不添加一个html标签。没关系。我仍然不确定如何解决收集。 – isea

+0

根据文档设置'boolean_style::inline'应该这样做.https://github.com/plataformatec/simple_form#stripping-away-all-wrapper-divs其他例子倾向于同样的事情,但声明略有不同。 '' – user3366016

对于一次性复选框,您可以使用其中的一个:

<%= f.check_box :hold %> 

<%= f.input_field :hold %> 

suggested here的新轨道。

对于集合,您可以根据docs设置boolean_style: :inline。其他例子倾向于同样的事情,但声明略有不同。

使用此:

<%= f.association :tasks, collection: Task.options_for_select, as: :check_boxes, required: false, boolean_style: :inline %>