tel8618217223380 / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

Label of TCheckBox not grayed out if checkbox is disabled #241

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Prado page with a disabled TCheckBox on it (Enabled=false)
2. Run the page/app

What is the expected output? What do you see instead?
You would expect that if a checkbox is disabled also the label attached to 
it will be disabled too, and appear grayed out, like the checkbox does. 
This isn't the case, however, as the label attached to the checkbox (and 
rendered by the checkbox itself) won't be disabled at all. This is very 
confusing to the user not only because he is used to checkbox labels being 
greyed out (as this is the case in most UIs) if the checkbox is disabled, 
but also because this way only the checkbox rectangle gets greyed out if 
it's disabled,  which, however - especially if unchecked - is practically 
indistinguishable from an enabled checkbox.

What version of the product are you using? On what operating system?
Prado/3.1.7

Please provide any additional information below.
To solve the problem the lines

    if(!$this->getEnabled(true))
      $writer->addAttribute('disabled','disabled');

need to be added to the TCheckBox::renderLabel() method, so the label 
attached to the checkbox will be disabled and grayed out too, if the 
checkbox control itself gets disabled.

Original issue reported on code.google.com by google...@pcforum.hu on 4 Apr 2010 at 10:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
To add the property disabled to the label. I find a solution below:

In TCheckBox.php find:
    protected function renderLabel($writer,$clientID,$text)
    {
        $writer->addAttribute('for',$clientID);

Right after, add:

        if(!$this->getEnabled(true))
            $writer->addAttribute('disabled','disabled');

After test, I worked correctly in IE but not Firefox.

After a study on Google, I tested and realized that the label disability is can 
just work in IE and not Firefox. So a work ground in changing its color to gray 
is all that I can do for now:

        if(!$this->getEnabled(true)){
            $writer->addAttribute('disabled','disabled');
            $writer->addAttribute('style','color:gray;');
        }

Original comment by lon...@gmail.com on 29 Sep 2010 at 6:07

Attachments:

GoogleCodeExporter commented 9 years ago
But I think, this is unnecessary for the label to grey out because for most of 
browsers (IE, Firefox, Chrome...) the standard label associated to a 
checkbox/radio won't grey out when its associated control being disabled (Try 
the label here http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_label - 
add property disabled="true")

So I suggest, this is not a bug, and if we want this behavior, just need to 
make a XCheckBox with a combination of a TLinkButton + TCheckBox and share this 
on the repository.

Original comment by lon...@gmail.com on 3 May 2011 at 10:05

GoogleCodeExporter commented 9 years ago

Original comment by ctrlal...@gmail.com on 10 Nov 2011 at 9:42