I don't think HABTM saves have changed from 1.1, so you should look at
the manual (Models, "Saving hasAndBelongsToMany Relations"), and
search this group, it has been covered before.
In your case, you will want to save something like:
if (!empty($this->data['Artist']))
{
// move the "genre_id" attribute into the Cake HABTM connection
$this->data['Genre']['Genre'] = array( $this->data['Artist']
['genre_id'] );
$this->Artist->create();
$result = $this->Artist->save($this->data);
}
Note - this is off the top of my head and I haven't used HABTM
associations much, but I think it's about right.
There have been a few helper functions made to enhance HABTM too, if
you just want to add / remove single associations rather than redoing
the whole lot.
http://bakery.cakephp.org/articles/view/alternative-methods-for-working-with-hasandbelongstomany-associations
http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---