How to validate email using Yii Model validation rules function code. Also how to check email exist or not using Model validation rules function in Yii.
You can set your model validations as below
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
//First parameter is your field name of table which has email value
array('email', 'email','message'=>"The email isn't correct"),
array('email', 'unique','message'=>'Email already exists!'),
);
}
Yii Reference Link For More Detail: http://www.yiiframework.com/wiki/56/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With