Checkboxlist Checkall Selected

How do I Select by default the checkAll option from the CheckBox list.

CHtml::checkBoxList(‘categories’, $selcat,$allcat ,array(‘checkAll’=>‘Select All’));

When the $selcat is empty I want the Select All option to be checked.


Any Help Please…

If all of the options are selected then the check all box will be selected by default. I guess you could include logic somewhere that does this:

if (!count($selcat))

    $selcat = array_keys($allcat);

It sets all of the options as checked, which is what you want if you’re checking the check all box.

Thnx Keith, you saved my Day…