On Wed, Aug 18, 2010 at 4:04 PM, Rob <[email protected]> wrote:
> Hey, this is my first time using google groups (im used to forums) so
> if this post is in the wrong are or something let me know.
>
> I have a cake php application and I'm using auth, acl, groups and all
> that jazz for users.  I have users being able to post content, but I'm
> having a problem finding out how to link the user to that content.
> Right now whenever a user posts something the user_id shows up as 0 in
> the database.  I'm pretty sure all my relationships are correct in my
> models.  I've tried making a hidden field in the my add.ctp view, but
> I'm not having any luck.
>
> Any help is appreciated, and if you need more info let me know.

What does the hidden field look like? It should be:

$form->hidden('Post.user_id', array('value' => $session->read('Auth.User.id')))

Alternatively (and also more secure), you can leave out the hidden
field and add the value to the data array in the controller before
saving.

$this->data['Post']['user_id'] = $this->Auth->user('id');

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

Reply via email to