我在编辑后填写了表单,表格未勾选复选框怎么做?这是我的代码。
.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}
感谢您的帮助!
答案 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