rails 4复选框标签未在编辑表单上选中

时间:2015-01-09 11:00:59

标签: ruby-on-rails

我在编辑后填写了表单,表格未勾选复选框怎么做?这是我的代码。

.available_days_div
  = label_tag "Available Days"
  br
  - ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"].each do |cld|
  = check_box_tag "available_days[]", cld, false, class: "fields_for_enabled available_days_check_box", id: "available_days_#{cld}_check_box", data: {day: "#{cld}"}
    | #{cld.humanize}

感谢您的帮助!

1 个答案:

答案 0 :(得分:-1)

来自:Rails - Default selected radiobutton in SimpleForm :collection

您应该将checked: 1添加到您的checkbox_tag

= check_box_tag "available_days[]", cld, false, class: "fields_for_enabled available_days_check_box", id: "available_days_#{cld}_check_box", data: {day: "#{cld}"}, checked: 1