CHtml::activeCheckBox validation

Hi qiang,

first of all, i'm a newbie and thanks for the great framework.

i am working on the registration process and need to use an activecheckbox to for user to agree the term of use. I checked help docs and post here in the forum but can not find the answer.

code @ view:

<?php echo CHtml::activeCheckBox($user,'termofuse');?>

code @ AR:

array('termofuse','CRangeValidator','range'=>'1'),

I've set a attribute here named $termofuse since there's no such column in the database.

i don't know if i made any mistake in the code and the result is the rule doesn't work. hope you can help me find out the problem. Thanks.

The range has to be an array. For CRangeValidator, you can use shortcut 'in'.

array('termofuse','in','range'=>array(1))

it's working. thanks.

BTW, is there any sample I can follow for a captcha validation?

Quote

it's working. thanks.

BTW, is there any sample I can follow for a captcha validation?

Well the blog demo has captcha validation for comments, You could look over that code.