Hello.
I’m using yii-user extension and i want to implement this kind of functionality: when user is registering he must accept checkbox : “i accept terms of use …etc”. Anyone implemented sth like that and can help me ?
Many thanks
Greetings
Tom
Hello.
I’m using yii-user extension and i want to implement this kind of functionality: when user is registering he must accept checkbox : “i accept terms of use …etc”. Anyone implemented sth like that and can help me ?
Many thanks
Greetings
Tom
Hi,
pelase add in the rules model
array('agree', 'required', 'requiredValue' => 1, 'message' => 'Please accept Terms and Conditons.'),
Many thanks for fast response. I tried to do it like you wrote, and i added this rule above to model: ProfileField (because “agree” field is added as a boolean profile field). Unfortunatelly, it doesn’t work. Field simply is not validating and it accept any value. I think that there is somewhere additional validating function for only profile fields. Additionally in yii-user for boolean fields there is always displaying dropdown list, but i want in this case to display checkbox. I can simply do this all when i’m not using yii-user but simply form, so maybe anyone implemented this using yii-user?.
Hi
Otherwise u can setflashmesasges
if($_POST['FrontRegisterValidationForm']['checkbox'] =="N"){
Yii::app()->user->setFlash('error', Yii::t("messages","Please Check the Terms and Privacy Condition.!"));
$this->render('index',array('model'=>$model));
Yii::app()->end();
}
I just completed the task of adding a check box for accepting terms as a profile field using the suggestions here and also other instructions found elsewhere. Here are the steps:
Add a field to the profile fields:
variable name: ‘agree’
title: ‘Accept Terms of Use’
field type: BINARY
required: Yes
error message: ‘Please check the box to accept the terms of use.’
position: 3
visible: ‘For all’
After creating the field go to the ‘Manage Profile Field’ Operation and add other validator: {“compare”:{“compareValue”:“1”}}
In the ProfileField model add to the rules: array(‘agree’, ‘required’, ‘requiredValue’ => 1, ‘message’ => ‘You must accept the Terms and Conditons in order to register.’),
In user/resgistration.php just below:
} elseif ($field->field_type=="TEXT") {
echo $form->textArea($profile,$field->varname,array('rows'=>6, 'cols'=>50));
}
add:
} elseif ($field->field_type=='BINARY') {
echo $form->checkBox($profile,$field->varname,array());
}
Many thanks Jamon. Greetings