checkBoxList


(Bas Vdl) #1

I need some help for changing the checkBoxList. I want that the ‘check all’ radio by default is selected.

How to achieve this?




<?php echo MyCHtml::checkBoxList('Categories', 

        $categories,

        CHtml::encodeArray(CHtml::listData(Category::model()->findAll(),

        'IdCategory',

        'Category')

    ),

    array('template' => '<li>{input} {label}</li>',

        'separator' => '',

        'checkAll' => 'Alle rubrieken')

    );

?>




(I Nedzinskas) #2

I think you must to extend this class to do this in the right way

found about extending http://www.yiiframework.com/forum/index.php?/topic/8769-extending-chtmlcheckboxlist/


(got 2 doodle) #3

@ignis You sent bas_vdl to his own post :D


(I Nedzinskas) #4

upps

well you can do this by writting some js or just with this little ‘hack’







$myData = CHtml::encodeArray(CHtml::listData(Category::model()->findAll();


$myData = empty($myData) ? categories : $myData;




echo MyCHtml::checkBoxList('Categories', 

        $categories,

        $myData,

        'IdCategory',

        'Category')

    ),

    array('template' => '<li>{input} {label}</li>',

        'separator' => '',

        'checkAll' => 'Alle rubrieken')

    );



Or you can wait for more advanced users answer