I have a user registration form with an email field that acts as a username and must be unique in the application.
User model has the following validation rules for this field:
var $validate = array( 'email' => array( 'email' => array('rule' => 'email', 'allowEmpty' => false, 'last' => true, 'message' => 'Valid email address required'), 'unique' => array('rule'=> 'isUnique', 'message' => 'Already exists'), ), );
In my controller, I want to check if this was a 'unique' rule that failed (to display various form elements, such as the "Send password to reset password" button).
I can check if the email field was valid or not ( if (isset($this->User->validationErrors['email'])) ), but how can I check the failure of a certain rule ?
Finding a specific error message like if ($this->User->validationErrors['email'] == "Already exists") simply wrong (l10n, etc.) ...
source share