A quick question I have working with a object in a rails 3 app and I would like to retain the checkboxes ticked (for example there are 3 options if someone chooses option 1 and 2 and refreshes the page the checkboxes 1 and 2 will remain ticked), this is very easy with radio buttons but I am still trying to get my head around it with checkboxes.
here is some code:
<%= form_for(@user, :remote => true) do |f| %>
<%= f.check_box :a1, {:multiple => true}, "1", "" %> <%= f.check_box :a1, {:multiple => true}, "2", "" %> <%= f.check_box :a1, {:multiple => true}, "3", "" %> <%= f.submit %> <% end %> <%= @user.a1.inspect %> output from the inspect element:
"---\n- ''\n- '1'\n- ''\n- '2'\n- ''\n" the user model has the a1 as a string in the db.
thanks in advance if anyone can help ,e
Regards Jon