When I go to edit page all my checkboxes are checked, while when I look in the html I have some of then set to false :
<input checked="false" class="hidden" id="cover_inspiration_image_ids" name="cover[inspiration_image_ids][]" type="checkbox" value="68">
I can't understand why the checked
value are not working.
I also tried with checked="checked"
I tried with jquery : $(".hidden").prop('checked')
and it return true
This is my code :
covers/_form
- @inspiration_images.each do |img|
- next if img.image.path.nil?
.w-col.w-col-2.w-col-small-4.w-col-tiny-6
label
INPUT[type="checkbox" name="cover[inspiration_image_ids][]" id='cover_inspiration_image_ids' value="#{img.id}" class="hidden" checked="#{check_status(img, @cover)}"]
.image-cov-pick
= cl_image_tag(img.image.path, height: 190, class: 'img-to-pick').html_safe
.white
cover_helper
module CoversHelper
def check_status(image, cover)
cover.inspiration_image_ids && cover.inspiration_image_ids.include?(image.id)
end
end