Actually, if you do a search, there isn't a whole lot of information
on this. There are a lot of questions, but no answers. Also, although
your solution didn't function, here's my controller action for others
that may need help.

function sign_up() {
        //debug($this->data);

        if (!empty($this->data)) {
                $this->cleanUpFields();
                $this->User->create();

                // Validate Company/User model at same time so we can grab 
errors
                // for both (even though the User model will be validated again 
in
beforeSave)
                $this->User->set($this->data);
                $this->Company->set($this->data);
                $company_validates = $this->Company->validates();
                $user_validates = $this->User->validates();

                if ($company_validates && $user_validates) {
                        if ($this->User->save()) {
                                $this->Session->setFlash('The User has been 
saved');
                                $this->redirect(array('action'=>'index'), null, 
true);
                        } else {
                                $this->Session->setFlash('Registration could 
not continue. Please,
try again.');
                        }
                } else {
                        $this->Session->setFlash('There were errors on the 
form.');
                }
        }
}

senser wrote:
> Did you try to search in group posts - there is a lot of info about
> this.
>
> Just a few words: in your controller function you should write "$this-
> >use('model_1', 'model_2', ..... 'model_n')" and something like:
> if($this->model_1->model_2->.......->model_n->save($this->data)){
>             //maybe last_insert_id
>             if($this->model_1->model_2->.......->model_n-1->save($this-
> >data)){
>               .............
>                            if($this->model_1->save($this->data)){
>                                       $this->flash('OK');
>                             }
>               }
> }
>
> You must have assigned associations in your models for  this models.
>
> On Nov 8, 10:32 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > I'm updating two models with one form, but I need to validate for each
> > model. What's the best way to accomplish this?


--~--~---------~--~----~------------~-------~--~----~
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