0

I have form filled after edit that form not checked the checkbox how do it? and this is my code.

.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}

Thanks for your help!

Karthick
  • 433
  • 1
  • 10
  • 25

1 Answers1

-2

from: Rails - Default selected radiobutton in SimpleForm :collection

you should add checked: 1 to your 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
Community
  • 1
  • 1
mswiszcz
  • 980
  • 1
  • 8
  • 26
  • I'm used your answer but checked all checkbox.i want what i'm checked that checkbox only visible.For example i checked monday so that checkbox only checked – Karthick Jan 09 '15 at 11:13
  • the easiest way would be to seperate the one you want checked from the loop – mswiszcz Jan 09 '15 at 11:35
  • You mean, you have filled this form with your data before, save this data and when you're visiting edit page for this model you don't see this checkbox checked, but all other fields are? If you provide full file it'd be better. Looks like it stores somewhere, but not in current model. So that no data received from server. – Stan Jan 09 '15 at 17:10