Checkbox onClick


I’m new to Yii, and I’m using the CRUD tool to interface to database.

I’ve a database field called “combo” DECIMAL(1,0), I’ve two issues with him:

1st: how can I bind him to the database field, I did the following in the _form.php

    <div class="row">

	<?php echo $form->labelEx($model,'COMBO'); ?>

	<?php echo CHtml::checkBox('COMBO',$model->COMBO); ?>

	<?php echo $form->error($model,'COMBO'); ?>


when the value is 1 it didn’t check the checkbox, or even when I create a new item it doesn’t affect the database for nothing.

2nd: how can I implement a JavaScript function like onClick event, I want to show/hide a div when checked changed, whether its value comes from the database or a user clicks on it.

Finally, thanks for your patience.


You need to check that is COMBO is safe attribute in your database model, secondly in checkBox, you can add onClick as

<?php echo CHtml::checkBox('COMBO',$model->COMBO,array(

'onclick'=>'your js function/call to js'

)); ?>


ThanQ for your reply,

but what you mean that COMBO is a safe attribute???

I means to say that if its values does not store in database, then you should declare it as safe attribute while creating/updating table entries.