Hi Doug,
I was hoping to give you a proof of
concept when I read your post this morning. Well, such are the plans, eh…
Anyway, my thought was:
You could create hidden fields for all
your checkboxes with initial values. You may also need an instance variable
array of these items, then in your action you could cycle through the array
and get the name of the checkbox and check its value in params.
Something like (please check the syntax
on all code):
controller-action: index
session[:check_boxes] = [a, b, c]
view template: index
<% form, :action=>‘create’ %>
<%= check_box_tag, a, :value=>off
%>
<%= hidden_field, a, :value=>off
%>
<%= check_box_tag, b, :value=>off
%>
<%= hidden_field, b, :value=>off
%>
<%= check_box_tag, c, :value=>off
%>
<%= hidden_field, c, :value=>off
%>
<% end %>
controller-action: create
@check_boxes = session[:check_boxes]
@on = 0
@off = 0
@check_boxes.each do |cb|
end
As I aluded to above, this is not tested.
Now, what I’m not sure of is how the interaction will work between hidden
fields and check_box field with identical names. There’s nothing wrong
with it, you have the same thing in a radio-groups, for example. I’m just
not sure which setting will ‘win out’.
Hope it gets you started. (Feel free
to reply to my gmail dot com account under the name dfdumaresq)
Regards,
Dave