Thursday, October 29, 2009

How to retrieve validation errors on model save?

Simple question:


I'm attempting to save a model, and the data to be saved is not
passing the validation rules. How do I retrieve the validation error?

if ($this->Ingredient->IngredientImage->save($this->data)) {
//success
$this->Session->setFlash(__('The Ingredient Image has been saved',
true));
} else {
// retrieve validation error and return to view
}


Also, am I correct in assuming that setFlash is useless in an ajax
call? I know I'm a noob but I'm not sure how I would use the setflash
and flash functionality in an ajax call. Any clue as to how to do this
would be most appreciated.


Thanks!
Will

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: