I want my checkboxes to be usable so I usually add label fors to the checkboxes so you can select the text instead of having to "aim" for the checkbox.
Problem is, what if I am using a nested attributes form in rails? I have this code for now:
%ul
- test_category.test_cases.each do |test_case|
%li
= check_box_tag "job_test_cases[]", "#{test_case.id}", test_case.id
= label_tag "test_case_#{test_case.id}", test_case.name
problem with this is that it produces this:
<li>
<input type="checkbox" value="70" name="job_test_cases[]" id="job_test_cases_" checked="checked">
<label for="test_case_70">Blah blah</label>
</li>
whereas I wanted it to be like this:
<li>
<input type="checkbox" value="70" name="test_case_id[]" id="test_case_70" checked="checked">
<label for="test_case_70">Blah BLah blah/label>
</li>
check_box_tag:/ Doesn't seem to match up with the docs at all api.rubyonrails.org/classes/ActionView/Helpers/…test_case.idas the 3rd arg and it is a bit confusing to me why your id/name values don't match up.