In the user model, you can set different rules for different scenarios. Such as, repeated password. The trick is to use the on=> parameter in your rules, which allows you to set the scenario that it applies to. Here’s an example of a rule used for registration only:

array('passwordVerify', 'required', 'on'=>'register'),

In your controller, the scenario you are using can be used when you instantiate your model

$model = new User('register');

…or set manually afterwards:

$model->scenario = 'register';

You also may want to consider using a separate model for this sort of purpose, to avoid any conflicting rules. See the Gii-generated LoginForm.php for an example of that.

Posted in: Yii

Related FAQ's

Marius Ion ANGEL HOT SOFT LLC (800) 316-7677