[EMAIL PROTECTED] wrote:
> that's not the way it works.... The method invalidate just puts field
> 'title' into invalid status and has no effect on save method.

Martin, that's not correct.  When *any* field is placed into invalid
status, a save operation will fail.  However, if you update a field
using Model::set( ), any associated validation error is removed (the
data changes, we no longer know if it is invalid or not).  When you
call Model::save( ) with parameters, those parameters are passed to
Model::set( ).  So the solutions are (a) use a model callback, as you
mentioned above, or (b) if you need to do some of your validation in
the controller (which there are many legitimate reasons to want to do),
you can do:

$this->Post->set($this->data);
$this->Post->invalidate('title');
if ($this->Post->save()) { // Now the save will fail.


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to