what parameters to add in my code?
$form->checkBox($model,'ATTRIBNAME',array("id"=>"mybox"));?>
i wanna display the checkbox as checked if the value from the db is 1 and unchecked if the value it got from the db is 0 ?
If the value of $model->ATTRIBNAME=1
then $form->checkBox(...)
method automatically check the checkbox, 0 for uncheck
$model->ATTRIBNAME = 1; // 0 for uncheck
//Now it displays checked box
$form->checkBox($model,'ATTRIBNAME',array("id"=>"mybox"));
チェックされた属性を追加する
if ($value==1) {$attrs=array("id"=>"mybox","checked"=>"checked");}
if ($value==0) {$attrs=array("id"=>"mybox");}
$form->checkBox($model,'ATTRIBNAME',$attrs);
Small code
$form->checkBox($model,'ATTRIBNAME',array("id"=>"mybox","checked"=>($value==1)?"checked":""));