I finally figured it out or at least one way of doing it.

Step 1 - Unbind the HABTM with the Associate model
Step 2 - Save User model data
Step 3 - bind HABTM with Associate model
Step 4 - save data['User']['id'] = getLastInsertID  <- for the
automagic to happen!!!
Step 5 - Save Associate data

Thanks for the suggestions.
Brian

On Jul 2, 2:15 pm, lirc201 <[EMAIL PROTECTED]> wrote:
> What is the "with" option?
>
> On Jul 2, 1:30 pm, francky06l <[EMAIL PROTECTED]> wrote:
>
> > If you use a join model (ie:HABTM) using 'with' option, the saveAll
> > will work if you also save the Associate (saving User, Associate and
> > the with Model).
> > If you do not have the Associate to save, just unbind and bind as
> > hasMany your liked model (the with), and call saveAll...
>
> > hth
>
> > On Jul 2, 6:28 pm, James K <[EMAIL PROTECTED]> wrote:
>
> > > It's best to just make a model for your join table, populate it
> > > manually and save it separately. There is an "automagic" way to do it
> > > - which is described in the manual - but it's just as much work and
> > > not very intuitive. The way the automagic works is you have to add an
> > > array of Associate keys you want to save into the join table in the
> > > User data collection (or vice-versa depending on which is the parent
> > > model). Then when you do user->save, it'll see that collection of keys
> > > and populate the join table.
>
> > > On Jul 1, 1:44 pm, lirc201 <[EMAIL PROTECTED]> wrote:
>
> > > > Hello All,
>
> > > > I'm stuck and need a jump start here.  I have a form that collections
> > > > User model and Associate model data.  User like email, password and
> > > > Associate like street, city, state, etc... data.   I have aHABTM
> > > > relationship between User and Associate.  My question is how to make
> > > > the linkage work?  In this case I'm assuming that both the User and
> > > > Associate data enter is new.
>
> > > > $this->User->save($this->data);
> > > > $user_id = $this->User->getLastInsertId();
>
> > > > at this point do I just this:
> > > > $this->data['User']['id'] = $user_id;
> > > > $this->Associate->save($this->data);
>
> > > > Will the join table get popualted?
>
> > > > Thanks,
> > > > Brian

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

Reply via email to