1
我怎樣才能簡單的表格,在標貼標籤我怎樣才能簡單的表格,在標貼標籤不換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">
我需要知道如何爲個人「保持」輸入和收集做到這一點。
你試過:'<%= f.check_box:持有%>'或'<%= f.input_field:持有%>'的[參考]( http://stackoverflow.com/a/18913719/3366016)更新的導軌。 – user3366016
我有。對於個人輸入,我將不得不添加一個html標籤。沒關係。我仍然不確定如何解決收集。 – isea
根據文檔設置'boolean_style::inline'應該這樣做.https://github.com/plataformatec/simple_form#stripping-away-all-wrapper-divs其他例子傾向於同樣的事情,但聲明略有不同。 '<%= f.association:tasks, collection:Task.options_for_select, as::check_boxes, required:false,boolean_style::inline%>' – user3366016