I have this terms and conditions checkbox and it’s a required field. I don’t know what happened but it works before and now it just doesn’t. I have looked all over but can not find anything that is wrong. I really appreciate if you can help. Thank you.
Can you post your code?
[html]<div class="row">
<?php echo $form->checkBox($model,'terms'); ?>
<?php echo $form->labelEx($model,'terms'); ?>
<?php echo $form->error($model,'terms'); ?>
</div>[/html]
public $terms;
public function rules()
{
return array(
array('terms', 'required', 'message'=>"You must accept the terms and conditions of the XXX to continue."),
);
}
-
Why have you added this line "public $terms;"?
-
When you say “it works before and now it just doesn’t”, what do you mean exactly?
Ok I guess “terms” isn’t an attribute in your db, you have it just to validate the form, right?
Try with:
array('terms', 'compare', 'compareValue'=>'1', 'message'=>'You must accept the terms and conditions of the XXX to continue.'),
The public $terms; is need because it’s a property inside a class that inherited from the CFormModel. Without it, the code will fail. This is standard and nothing new.
It works before but someone modified something and now it doesn’t. I don’t know exactly what they modified and I cannot find anything that indicates what they have changed.
This suggestion works great. Thank you. I waste some much time using the required check.