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" <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---