Am I going totally nuts here and just want to check (Natch!) something.
A normal check_box has two value posssibilities. One for checked and one
for unchecked, the value gets submitted with a form.
The check_box_tag on the other hand, has a checked_value (Called just
‘value’) and for the unchecked value…nothing, zip, nada.
This means that if you submit a form with a check_box_tag in it and it
is unchecked there is absolutely nothing in the params, not :checkbox =>
0…Am I the only one that is having trouble with this?
In my controllers I have a method that can be called from two different
places. One is from a form and another is from a link in another view.
My method is currently setup to behave differently depending on the
value of the checkbox.
I store the value in a session for future use (since it is a
semi-persistant value). The idea is to set the value of the checkbox
using the form and when the controller is called with
params[:checkbox].nil? it just uses the one stored in the session.
However since the check_box_tag is either value or nil I can’t use this
method. Is it just me or does this make no sense? That the check_box_tag
has less functionality than the normal check_box. I am thinking of
modifying the taghelper code so that the tag matches the normal one but
I would rather not deviate from normal rails.
Am I missing something totally obvious or is check_box_tag limited
to the proper check_box helper?