Validator "on" property

What does it mean by scenarios?

Is this NOT the controller method? If not is it possible to do it by controller method name?

u can use CFilterValidator for that purpose. can run ur custom function on the attribute value.

For the most part, controller methods can be used to distinguish between scenarios: update, delete etc.

The “on” property is useful when you have “sub-actions”. Consider the User model. A user can change his pwd and change his email address via 2 different forms. Both of these actions will, by default, call the Save method and subsequently will call the CActiveRecord’s Update method.

You probably do not want pwd and pwd_repeat to be required in the change email form. You can can call:


in the controller to distinguish between the two scenarios.



I thought the save() method takes true or false depending on whether you want it to validate or not?

Is "changePwd" creating the scenario for the save? As simple as that?

You can set the scenario on the model or pass as parameter in create.

The parameter of save is only "wether to run validation"

Try like that:




$user = new User('changePwd');

Fantastic, thanks.

True, sorry 'bout that.