controller::add
$this->set('user_id', $user_id);

views:
echo $form->create('Profile', array('action' => 'add'));
echo $form->hidden('Profile.user_id', array('value' => $user_id));

echo $form->create('Profile', array('action' => 'edit'));
echo $form->hidden('Profile.user_id');

You shouldn't need to set the user_id value in edit.ctp because you
will have read the Profile fields into $this->data. The FormHelper
will deal with it.

On Mon, Mar 9, 2009 at 6:32 PM, Paulos23 <paulitosthe...@gmail.com> wrote:
>
> Hi people,
> I have much trouble in creating a profile which is reffered to a
> specific user.I have made the relation User hasOne Profile and Profile
> belongsTo User.Then i put CRUD functionality in User with
> add,view,update and delete.After that in user/view i put the same CRUD
> fanctionality for the profiles this time.But when i want to create a
> Profile for a user the user_id remains 0 and this means it cant be
> related to the specific user.Can you plz help me with some sample
> code?
>
> Thx in advance
>
> >
>

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