Reputation: 95
validation code is
return array(
array('firstname, lastname, confirm_email, education, email, password, occupation,location , birthdate, interest,gender,created, modified', 'required'),
array('email', 'email'),
array('password', 'length', 'max'=>20, 'min' => 5,'message' => "Incorrect fi (length between 5 and 20 characters)."),
array('firstname', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('email', 'unique'),
);
Upvotes: 6
Views: 10989
Reputation: 2080
You may make your email unique in yii user model by the following rule as given in below.
public function rules() {
return array(
...
array('email', 'email'),
array('email', 'unique', 'className' => 'User',
'attributeName' => 'email',
'message'=>'This Email is already in use'),
...
); }
Here className is the name of your user model class, attributeName is your db email field name.
You may also check the below link.
Thanks
Upvotes: 14
Reputation: 867
public function rules()
{
return array(
...
array('email', 'email'),
array('email', 'unique'),
...
);
}
Upvotes: 6
Reputation: 1540
Try this:
As per your given code, It seems ok
You can verify using this url about validation:
http://www.yiiframework.com/doc/guide/1.1/en/form.model#declaring-validation-rules
Upvotes: 0