Thanks for the reply mscdex I think if you do it the way I posted (put the field in Tag) you don't need bindModel at all. You can also use save() and not saveAll().
On Mar 5, 2:28 am, mscdex <[email protected]> wrote: > On Mar 4, 6:52 pm, Omi <[email protected]> wrote: > > > The correct way is to set > > $this->data['Tag'][0] = array( > > 'tag_id' => $foo, > > 'tagger_id' => $bar > > ); > > This is kinda on the right track. Here's an example of what I used for > a Movies sample project: > > views/movies/add.ctp: > <?php > echo $form->create('Movie'); > echo $form->input('Movie.name'); > echo $form->input('MoviesUser.0.user_id'); > echo $form->input('MoviesUser.0.ranking'); > echo $form->end('Submit'); > ?> > > controllers/movies_controller.ctp: > function add() { > if (!empty($this->data)) { > $this->Movie->create(); > > $this->Movie->bindModel(array('hasMany'=>array('MoviesUser')), > false); > if ($this->Movie->saveAll($this->data)) { > $this->Session->setFlash(__('The Movie has > been saved', true)); > $this->redirect(array('action'=>'index')); > } else { > $this->Session->setFlash(__('The Movie could > not be saved. Please, > try again.', true)); > } > } > $users = $this->Movie->User->find('list'); > $this->set(compact('users')); > } > > IIRC the key was to do a bindModel with the name of the join relation > name as a hasMany association before saving. > > Hope that helps some. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
