Check_box_tag and :disabled => 'disabled' problem


#1

I’ve been using the check_box_tag to generate checkboxes for an
application
I am working on and I’ve run into a little hiccup.

When I set the options for the checkbox to be { :disabled => “disabled”
}
the checkbox becomes disabled, as I would expect. However, if I set the
checked value to true and keep the disabled option, the value for the
checkbox is not returned. Is this expected behavior? Is this how regular
HTML handles this situation?

What I am trying to accomplish is to provide the user with a list of
items
(of which they are editing one) and allow them to apply the changes to
other
similar items. However, I want them to be able to see that it will be
applied to their item, but I don’t want them to be able to uncheck the
box.
Thus, the disabled attribute.

My work around, if you can even call it that, is to just get rid of the
disabled options. Anybody have a suggestion or ideas on how I can get
disabled to play nice and return a value if the disabled box is checked?


#2

Ryan P. wrote:

When I set the options for the checkbox to be { :disabled => “disabled”
} the checkbox becomes disabled, as I would expect. However, if I set
the checked value to true and keep the disabled option, the value for
the checkbox is not returned. Is this expected behavior? Is this how
regular HTML handles this situation?

This is as described in the HTML specification. Only the values of
‘successful’ controls are returned. Controls that are disabled are not
successful and therefore are not returned. See
http://www.w3.org/TR/html4/interact/forms.html#successful-controls

What I am trying to accomplish is to provide the user with a list of
items (of which they are editing one) and allow them to apply the
changes to other similar items. However, I want them to be able to see
that it will be applied to their item, but I don’t want them to be able
to uncheck the box. Thus, the disabled attribute.

Note that it is always possible for the user to change the value of a
disabled control (for example, by using javascript or by building their
own form that posts to your server).

Can you not do the calculation to determine the other items again when
the form is submitted? This way the disabled checkboxes would just be
there for show - their values would be unimportant.


Philip R.
http://tzinfo.rubyforge.org/ – DST-aware timezone library for Ruby


#3

What I can do is change the wording to something like “Also add this
to…”
and not display the current item and force it to post to it. That’s the
work
around that I’ve been looking into and seems the most feasible for my
given
situation.

Thanks for your reply Philip, I really appreciate it.

Best,
Ryan