Forum: Ruby on Rails check_box_tag and :disabled => 'disabled' problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eed3ca2591560a2dd91222d9b62f882d?d=identicon&s=25 Ryan Prins (Guest)
on 2006-04-27 23:26
(Received via mailing list)
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?
9ab183bb240ffd3a3966d5a615b4bdeb?d=identicon&s=25 Philip Ross (Guest)
on 2006-04-28 02:02
(Received via mailing list)
Ryan Prins 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#suc...

> 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 Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
Eed3ca2591560a2dd91222d9b62f882d?d=identicon&s=25 Ryan Prins (Guest)
on 2006-04-28 05:24
(Received via mailing list)
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
This topic is locked and can not be replied to.