lundi 27 juillet 2015

How to checkbox as checked with check_box_tag

I have the following code in Rails that is supposed to set the checkbox to "checked":

check_box_tag :email_subject_confirmation, 1, true, {id: "email-subject-confirmation", class: "confirmation-checkbox"}

And indeed, it does:

<input type="checkbox" name="email_subject_confirmation" id="email-subject-confirmation" value="1" class="confirmation-checkbox" checked="checked">

...but the checkbox does not appear to be checked. What gives?

And when I manually "check" the box, there is no indication in the markup that it is checked:

<input type="checkbox" name="email_subject_confirmation" id="email-subject-confirmation" class="confirmation-checkbox">

...but the form submits as desired. What's going on behind the scenes? How can I make a check_box_tag checked on page load without resorting to explicity Javascript?




Aucun commentaire:

Enregistrer un commentaire