Topic: checkboxes and loops.
I'm really having some problems here. what I've done is looped a bunch of checkboxes, but I can't get them to apply the settings. I'm sure its to do with how the form is being written, but I cant seem to pass any useful information to it.
okay database is. and I will loop through each row, and the checkbox will be ticked if leader is = 1
id
user_id
squad_id
leader (1 or null)
created_on
view looks like - which is where I think I'm having the problem with.
<% for squad in @squads -%>
<% @membership = Member.find(:first, :conditions => ["user_id = ? and squad_id = ?", @selected_user.id, squad.id]) %>
<dd>
<%= check_box(:membership, :leader, {}, "1", "0") %> -
<%= squad.name %> [<%= squad.tag %>]<br>
</dd><% end -%>
output of the view is
<input checked="checked" id="membership_leader" name="membership[leader]" type="checkbox" value="1" /><input name="membership[leader]" type="hidden" value="0" /> -
Battlefield 2 [BF2]<br>
</dd>
<dd>
<input id="membership_leader" name="membership[leader]" type="checkbox" value="1" /><input name="membership[leader]" type="hidden" value="0" /> -
Counter-Strike: Source [CSS]<br>
</dd>
.....
I cant seem to make it pass the squad id into the checkbox.
and when updating can I use some sortta batch update? or do I have to create a model with a loop in it and up date each one?
thanks
Last edited by BasicMind (2006-12-04 16:03:51)