If you have both id's you should just save directly in to the join table. $data['ColoursProduct']['product_id'] = 1; $data['ColoursProduct']['colour_id'] = 2;
$this->Product->ColoursProduct->save($data); Note, the join table model is auto-created for you... I have a few other posts that describe that in more detail. On Nov 18, 5:12 am, Hipnotik <[EMAIL PROTECTED]> wrote: > On 17 Lis, 15:03, Joel Perras <[EMAIL PROTECTED]> wrote: > > >http://teknoid.wordpress.com/2008/07/11/notes-on-cakephp-habtm-part-2... > > It's not the same :( > I have products and colours defined and I need "only" to bind these > models, such as "select product, select colour and click save". > > > -J. > > > On 17 Nov, 07:00, Hipnotik <[EMAIL PROTECTED]> wrote: > > > > Hi Anja, > > > thanks for your reply. > > > > My first idea how to do that was same as your... but I started to > > > think of it and there should be "a more clever" way, I think. > > > > On 17 Lis, 12:04, "Liebermann, Anja Carolin" > > > > <[EMAIL PROTECTED]> wrote: > > > > Hi Hipnotik, > > > > > You would need a controller and model for the realtion also. > > > > > I have the same situation with some of my models and work woth a third > > > > model which gives me the connection between then like > > > > Conncolourproduct.php and conncolourproducts_controller.php > > > > > Maybe someone has a more clever solution? > > > > > Anja > > > > > -----Ursprüngliche Nachricht----- > > > > Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von > > > > Hipnotik > > > > Gesendet: Montag, 17. November 2008 11:13 > > > > An: CakePHP > > > > Betreff: How to add colour to product? [Models associations/relations, > > > > habtm?] > > > > > I have problem. > > > > I have 3 tables: > > > > 1. products > > > > 2. colours > > > > 3. colours_products > > > > > There are also 2 models: > > > > 1. Product > > > > 2. Colour > > > > with set up associations > > > > Product model: var $hasAndBelongsToMany = array("Colour"); Colour > > > > model: var $hasAndBelongsToMany = array("Product"); > > > > > I created a view with form with 2 select boxes where the first one > > > > contain products list and second available colours. I would like to > > > > select a product then select a colour and click on Save button to save > > > > product->colour relation. I have a controller to display data but I > > > > don't know how to create proper add action. > > > > > How to save data from form like this? > > > > How form initialization line should be looking (I mean echo $form- > > > > > >create("Colour", array("action"=>"add"));)? > > > > > Thanks for help > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---