CHtml::activeCheckBox() seems to post '1' when checked, but an empty string ('') when unchecked. I want a single checkbox for a bunch of attributes (such as email_publicly_visible) which have boolean values. When the checkbox is unchecked, I get a mysql error because it can't store null into the column.
Should CHtml::activeCheckBox() actually post '0' when unchecked? Is that a bug?
Should an argument be added to it that defines what the value is when unchecked?
Ok. Yes, it is definitely not needed, but I think it would be less typing. And I don't see why the type validator should not support it anyways, it is a ''data type" after all.
I want to validate checkBox to know user accept terms and conditions. But the validation is not works.
I did like this:
In model
public function rules()
{
return array(
array('terms', 'required'),
array('terms', 'length', 'min'=>1,
'message'=>'You must accept to continue....'),
);
}
public function rules()
{
return array(
array('terms', 'required'),
array('terms', 'CRangeValidator', 'range'=>array(1),
'message'=>'You must accept to continue....'),
);
}