Well first of all, you're calling validates() before you're calling
save(), so the data that gets set in save() isn't there in the
validate() call.
Also, if you're doing any custom validation in your controller, you
should use set() to set the data to the model, and call save() with no
parameters. Otherwise, save() will call set(), and when a previously
invalidated field gets overwritten, the validation error goes away
(which is only logical, since the data has changed).
Additionally, the call to validates() is unnecessary, since save() will
validate by default, and return false if validation fails. Thus, your
new code should look more like the following:
$this->User->set($this->data);
if (!$this->fooBar('someData')) {
$this->User->invalidate('name');
}
if ($this->User->save( )) {
[ Do some cool stuff ]
}
(The model code is fine as-is.)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---