Using the 'on'=>'scenario' option


I want to implement the 'on'=>'scenario' way of defining a rule. I've defined the rules thus:

array('PASSWORD, PASSWORD_REPEAT, EMAIL', 'required', 'on'=>'create'), 



   			array('EMAIL', 'unique', 'on'=>'create'),


   			array('PASSWORD', 'compare', 'compareAttribute'=>'PASSWORD_REPEAT', 'on'=>'create'),

My real problem comes from the fact that this form is not used independently, but is used respectively in the views of userFirms and userPersons.

This is the validation and save code:

	$users->attributes = $_POST['users'];

		$users->USER_ID                 =     $UserID;

		$users->PASSWORD_REPEAT         =     $_POST['users']['PASSWORD_REPEAT'];

		$users->TYPE                    =     "2";

		$userpersons->attributes = $_POST['userPersons'];

		$userpersons->USER_ID  	        = $UserID;

		$result1 = $users->validate();

		$result2 = $userpersons->validate();

The action is called "create", but it is an active from the userPersons controller, not from users. Therefore, defining the rules with 'on'=>'create" in users model doesn't make sense as I don't call them in the create Action in the users controller, but in the create action in the userPersons controller.

Which is the best approach to solve my problem?

Thanks in advance.

The scenario name has nothing to do with action name. It is passed as a parameter to the validate() method.


Thanks guys! I understood that I was in mistake.