ok after two close nervous breakdowns i got it. for everyone else who has probs with habtm saving: used this behaviour
http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior works pretty fine..... :) On 18 Sep., 16:39, Tomfox Wiranata <[email protected]> wrote: > hi everyone, > > I have two models: User and Product with tables users and products. > there is a HABTM relation involved. > > so I coded in the product model: > > var $hasAndBelongsToMany = array( > 'User' => > array('className' => 'User', > 'joinTable' => 'users_products', > 'foreignKey' => 'product_id', > 'associationForeignKey' => 'user_id' > ) > ); > > now i have a function in my products controller, that is supposed to > save this relation in the m:n table "users_products": > > function rememberThisProduct() > { > $this->data['????????']['user_id']= $this -> Session -> > read('User.id'); > $this->data['????????']['product_id'] = $this->Product->id; > $saved = $this->????????->save($this->data); > > if($saved){ > $this->render('message','ajax'); > } > > } > > now i filled the blanks with questions marks because I dont know if I > need to create a model UserProduct or not, and what model do I have to > take in the saving process? > > I appreciate your help. thank you! 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
