Does the User already exist? Or, is the User being created at the same
time as the event?

Either way, if you create the event with the Event controller, all you
need to do is make sure there's a hidden field for Event.user_id and
that its value is set to the User.id.

On Fri, Jan 16, 2009 at 11:45 PM, mike <mwu...@gmail.com> wrote:
>
> I'm not sure I understand this.  How would the user controller know
> which event its supposed to be related to?
>
> I have the user model set to hasMany Events, and Event belongsTo
> User.  In the view I have the hidden field as suggested.
>
> then I tried this:
>                $this->data['Event']['user_id'] = 
> $this->User->getLastInsertId();
>                $this->User->Event->save($this->data);
>
> but this just adds a new row to the event table, instead of updating
> the last inserted one.
>
> On Jan 16, 10:43 pm, "Jon Bennett" <jmbenn...@gmail.com> wrote:
>> >  However, wouldn't it make more sense to submit the User info before
>> >  the Event info? I assume that a User hasMany Event. In which case,
>> >  you'd have the User submit their info and ensure that
>> >  $this->data['User']['id'] was set before rendering (not redirect to)
>> >  the Event form view, which would have:
>>
>> >  echo $form->hidden('User.id');
>>
>> If this is going in a form tied to the Event model, shouldn't it in fact be:
>>
>> // hidden form input for foreign key in events table
>> echo $form->hidden('Event.user_id');
>>
>> hth
>>
>> jon
>>
>> --
>>
>> 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 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to