If you are interested in the details, I wrote an article and explained why you need to do it this way: http://www.dereuromark.de/2010/06/20/validating-multiple-models-at-once/
cheers mark On 20 Jun., 12:18, euromark <[email protected]> wrote: > actually its quite easy for multiple model validations > > $this->Post->set($this->data); > $this->Post->User->set($this->data); > > $val1 = $this->Post->validates(array('fieldList'=>$val1List)); > $val2 = $this->Post->User->validates(array('fieldList'=>$val2List); > > if ($val1 && $val2) { // OK } else { ... } > > cake automatically passes the errors to the view > the field list part is optional > > note: the set part is very important in this case (thats what you > missed) > > On 20 Jun., 09:33, Melanie Sommer <[email protected]> > wrote: > > > > 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. > > > Yes it does and it works beautifully - but not for input fields that > > do not belong of the current model. > > > If my Model1 has only Model1.fieldA, Model1.fieldB and Model1.fieldC > > and I have a second Model2 with fields Model2.fieldD and Model2.fieldE > > and I am using Model1/add > > then, validation errors for Model2.fieldD and Model2.fieldE are not > > displayed. > > > I looked at the definition of the FormHelper and what I understand is > > that FormHelper calls the function tagIsInvalid() that returns an > > array with all the errors of the current model (or: input names). > > I thought that there might be a way to add the errors of other models > > to that array, so that cake also displays errors the errors of Model2 > > and not only Model1. > > > I do not know whether this is the way to do that. > > > How can I generally display errors for an input field if cake does not > > do it automatically? I did not find anything in the cookbook for > > FormHelper. > > > 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 [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
