Try
$data['User']['id'] = 1010;
$data['Profile'][0]['id'] = 1234;
$data['Profile'][1]['id'] = 5678;
foreach ($data['Profile'] as $i=>$v):
$data['Profile'][$i]['user_id'] = $data['User']['id'];
endforeach;
$this->User->save($data);
$this->User-->Profile->saveAll($data);
I dont know if doing $this->User->saveAll($data) will save the User and
Profile data
---
Norman Paniagua
2010/7/26 sanedevil <[email protected]>
> For my problem, a User HABTM Profiles
>
> A user can select multiple profiles via a screen. I get these values
> in my controller. I want to "link" all these profiles with the user.
> Currently i'm doing:
>
> $profile_1['Profile']['id'] = 1234; //the profile id
> $profile_1['User']['id'] = 1010; // The user id
> $this->User->save($profile_1);
>
> $profile_2['Profile']['id'] = 5678; //the profile id
> $profile_2['User']['id'] = 1010; // The user id same as
> before
> $this->User->save($profile_2);
>
> However, this creates only the 2nd link in the HABTM table.
>
> Is there a way that I can create both the links (1010-1234 and
> 1010-5678) in a single shot?
>
> Thanks!
>
> 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]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
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