I have a form with multiple models in it. The validates in the models seems correct and the models are associated properly. But how do I invalidateFields from two models and pass the display error back to the form?
Code in my users)_controller.php is:
$errors = $this->User->invalidFields(array('fieldList' => array('password','cpassword','firstname','lastname','email')));
$this->User->set('errors',$errors);
But I have a Profile model chained like this:
$this->User->Profile
and want it to invalidFields to Profile.zip.
Instead of manually setting errors in the invalid fields array, I would suggest to use the
$validate
array to set up validation rules.You can define your own, complex rules if the built in ones are not enough.