views:

39

answers:

1

i use validation in model like this

'email' => array( //'UniqueMail'=>array('rule' => array('checkEmailUnique', 'email' ),'message' => 'mail is used'), 'email'=>array('rule' => 'email','message' => 'mail not valid'), 'notEmpty'=>array('rule' => 'notEmpty','message' => '*'), )

and this validation for field email but in some other form idon't want to check the unique mail validation . how i can do this

regards

A: 

Do not add that rule to your $validates array.

Create a beforeValidate() callback in your model.

In the beforeValidate() callback check for the presence of a flag in the form data (something like $data[$this->alias]['checkMail']. If the flag is set, then add the email validation rule to your $this->validates array. This will prevent you from validating against that rule unless you specifically tell the model to do so.

Darren Newton