I am using check_box_tag in a form helper and all the other fields preserve their inputs after a submit validation error, but check_box_tag does not. Is there some way to get check_box_tag to save its state on a failed form submit? Here’s the code:
<%= check_box_tag 'user_ids[]',
user.id,
false,
:class => 'user_checkbox' %>
I need to use check_box_tag instead of check_box in this context.
You’re passing
falsetocheck_box_tagso all checkboxes are disabled. To fix that you can do smth like:It checks whether
user.idwas among user ids that were submitted and if it was then checkbox is checked.