Hello All!!

Before posting this I searched around this group, the cake manual, and
api but was unable to find any information related to my problem. I am
hoping someone here knows of a solution or can point me to information
related to what I am trying to do.

I have the need to programmatically create and add additional items to
a HABTM relationship. I wrote the following:

$this->User = new User;
$user = $this->User->create(array('username' => $uname));
$user['Tag'] = array();
array_push($user['Tag'], $auth_tag['Tag']);  //$auth_tag is a valid
object

$this->User->log($user);

$this->User->save($user);


The log shows the object I created looks as follows:

Array
(
    [User] => Array
        (
            [username] => test
        )

    [Tag] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [name] => phpCAS
                    [created] =>
                    [modified] =>
                    [tag_type_id] => 1
                )

        )

)

Which appears correct. The save does save the User object but does not
create the Tag relationship. I also attempted to do this on an
existing object:

$user = $this->User->findByUsername('test');
array_push($user['Tag'], $auth_tag['Tag']);

$this->User->log($user);

$this->User->save($user);

But still is does not save. Has anyone run into similar issues? Any
suggestions on how I might archive this functionality?

Thanks in advance for all the help!!!!

-M
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to