CCompareValidator seems not working

I built a simple registration form -


class MRegistrationForm extends CFormModel {


	public $email;

	public $password;

	public $password2;


	...

}

with several simple validation rules


 public function rules()

	{

	  return array(

		   	array('email, password, password2', 'required'),

           	array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'), // this line is not working

		   	array('email', 'email')

		   	);

	}

All other validation rules work, except ‘compare’ validation. I copied this line of code directly from the Guide http://www.yiiframework.com/doc/guide/1.1/en/form.model

Can you tell me what seems to be the problem? Thank you!

Regards,

Nicolas Xu

the ‘on’=>‘register’ part says to apply that validation only for the ‘register’ scenario… do you have that scenario?

Try without that part to see if it’s working…

Thanks for the tip! My mistake is that I think scenario is a member function, but according to the Guide, it’s an attribute that inside the model.