Re: validation errors
Ordinary all you need is:
if ($this->Model->save($this->data)) {
// success code
}
else {
// failure code
}
Because Cake do not save if validation failed and pass validation
errors to view automatically. Form helper render these errors when use
$from->input() method.
On Jun 19, 2:06 pm, Melanie Sommer <melanie-som...@mailinator.com>
wrote:
> Hi,
>
> In an add view I have several input fields that contain data for more
> than one model. I sort, validate and save this data in the controller
> using
>
> if($this->Model->validates()){
> $this->Model->create();
> if($this->Model->save($data)){
> ...
> }else{
> ...
> }}else{
>
> $errors = $this->Lamp->invalidFields();
>
> }
>
> In case of validation errors, is there a clever way to get the $errors
> array to the view? I think cake stores the validation errors of the
> current model in an array, which seems to be somehow associated with
> $form->tagIsInvalid()
> Is there a way to add the errors of the other models to that array to
> use cakes automagic behaviour to display the error?
>
> Thank you for your help!
> Melanie
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home