Having time with this; I am convinced that I simply won’t get something completely obvious, because I can’t imagine it to be difficult. Everything else works in my form, but on initial display, the checkboxes are not checked when they should be. Here's the corresponding erb:
<%= form_for :project, :url=>{:controller=>'projects', :action=>'update_permissions', :id=>@project.id} do |f| %> <fieldset> <% @project.contributors.each do |contributor| %> <%= f.fields_for "contributors[#{contributor.id}]" do |c| %> <ul id="PermissionsList" class="permissions-grid in-line clearfix full"> <li> <ul class = "clearfix permission-row"> <li class="first"> <%= c.check_box :is_active %><label for="<%= contributor.id %>"><%= contributor.user.whole_name %></label> </li> <% @roles.each do |role| %> <li><%= c.radio_button :role_id, role.id, :id=>"#{contributor.id}-#{role.id}" %><%= label "#{contributor.id}-#{role.id}", role.role_name %></li> <% end %> </ul> <% end %> </li> </ul> <% end %> </fieldset>
I pass the is_checked attribute (for the current contributor) to the check_box helper. Is this the right way to do it right? Here's what the generated markup looks like:
<ul class="clearfix permission-row"> <li class="first"> <input type="hidden" value="0" name="project[contributors[9]][is_active]"><input type="checkbox" value="1" name="project[contributors[9]][is_active]" id="project_contributors_9__is_active"><label for="9">Bill Hatch</label> </li> <li><input type="radio" value="1" name="project[contributors[9]][role_id]" id="9-1" style="display: none;"><label for="9-1_Reviewer" style="display: none;">Reviewer</label></li> <li><input type="radio" value="2" name="project[contributors[9]][role_id]" id="9-2" style="display: none;"><label for="9-2_Tech. Reviewer" style="display: none;">Tech. reviewer</label></li> <li><input type="radio" value="3" name="project[contributors[9]][role_id]" id="9-3" style="display: none;"><label for="9-3_Contributor" style="display: none;">Contributor</label></li> </ul>
The checkbox value is 1, as it should be, so I'm a little confused as to why it does not appear as verified. As I said, I’m sure I just missed something obvious; in no way can it be so complicated; -)
source share