Re: $this->User->modelA->save doesn't key modelA properly

2009-12-02 Thread John Andersen
In your ModelA controller, you have to add the users id manually
before invoking the ModelA save.
If you are using Auth, then get the users id from $this->Auth->user
('id') /* From my memory */ and add it to the data array before
invoking ModelA.

By using $this->User->ModelA does not automatically add the users id
to the data array! It only tells the Controller how to get to the
ModelA. But anyway, the User model is not needed in the ModelA
controller, only the ModelA model.

Enjoy,
   John

On Dec 3, 6:41 am, Christian  wrote:
> User has many ModelA
> So in the ModelA Controller, I replaced every $this->ModelA with 
> $this->User->ModelA so every action done is user specific. The index action
>
> successfully shows only that users ModelA's, however the add() action
> creates ModelA with user_id = 0 everytime.
>
> If this is the intended functionality, then how do you manage users on
> yours sites that have their own exclusive instances of a model. I
> could just.. search the users for the one currently logged in, and
> manually place the foreign_key in.. but I'd like to think this kind of
> behaviour is natural given the rest of the framework's automagic.

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


$this->User->modelA->save doesn't key modelA properly

2009-12-02 Thread Christian
User has many ModelA
So in the ModelA Controller, I replaced every $this->ModelA with $this-
>User->ModelA so every action done is user specific. The index action
successfully shows only that users ModelA's, however the add() action
creates ModelA with user_id = 0 everytime.

If this is the intended functionality, then how do you manage users on
yours sites that have their own exclusive instances of a model. I
could just.. search the users for the one currently logged in, and
manually place the foreign_key in.. but I'd like to think this kind of
behaviour is natural given the rest of the framework's automagic.

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