> OK, I guess you do have to save more things than I was hoping for. For
> future reference, my updated controller looks like:
>
> foreach ($this->data['Tag']['Tag'] as $item)
> {
> $this->Tag->create();
> $this->Tag->save(array('Tag' => array('tag' =>
> $item)));
> $tag_id[] = $this->Tag->getLastInsertId();
> }
>
> $this->data['Tag']['Tag'] = $tag_id;
>
> $this->Image->save($this->data);
>
>
> By filling the $this->data['Tag']['Tag'] array with the ID's of the
> tags we just inserted, then the HABTM *then* fills in the correct
> items in the link table.
ahh yes, sorry, I kinda assumed the Tag already existed, and you were
just linking the new Image to it. The thing to remember is a HABTM is
just a join record between 2 models, so it can only exist if both
records in both models already exist.
Are you accounting for duplicate Tag names in your Image upload code?
cheers,
jb
--
jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---