Ryan Prins
2006-Apr-27 21:27 UTC
[Rails] check_box_tag and :disabled => ''disabled'' problem
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? -- Ryan Prins rprins@gmail.com http://www.lazyi.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060427/364e957f/attachment.html
Philip Ross
2006-Apr-27 23:59 UTC
[Rails] Re: check_box_tag and :disabled => ''disabled'' problem
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#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 Ross http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
Ryan Prins
2006-Apr-28 03:22 UTC
[Rails] Re: check_box_tag and :disabled => ''disabled'' problem
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 On 4/27/06, Philip Ross <phil.ross@gmail.com> wrote:> > 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#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 Ross > http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ryan Prins rprins@gmail.com http://www.lazyi.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060428/cdbb2c9a/attachment.html