I just want to print a checkbox and have it be checked/unchecked depending on some database value. The problem I face is that the CCheckBoxColumn class does funny things.
I found this, but it didn’t help:
The reason being that the $headerCheckBoxVisible variable/property/whatever doesn’t exist in the CheckBoxColumn class. I couldn’t even find it in the source code (https://github.com/yiisoft/yii/blob/1.1.14/framework/zii/widgets/grid/CCheckBoxColumn.php).
If I do the following:
The header (“Activar” in this case) is removed and replaced with a checkbox to select/deselect all available checkboxes. If I remove the ‘selectableRows’ property, the header “Activar” is available but only one checkbox can be selected at the same time.
This is a problem. My user won’t know what that column is supposed to do if the text is removed, but if I have the text in the header only one checkbox will be used and it will confuse the user.
I just want to print the checkboxes with preselected values of check/uncheck, some htmlOptions, and the client side code will do the rest.
I tried doing it with CDataColumn and just print the checkbox HTML into the value property, like the following:
But the characters are escaped and I just get text instead of the checkbox input.