Tuesday, May 29, 2012

Re: Extend model/datasource to save user_id on create, update

Il 29/05/2012 15:23, GB ha scritto:
> [...]
> I recall seeing this long ago but cannot find in any archives. Can
> anyone point me to resources on how to do this? I suspect it means
> extending the model in AppModel but wasn't sure if more appropriate
> extending the Datasource.
>
> Thanks!
>
> George
>
Hi,
I had this done before with a behavior callback, like beforeSave.
Check if a magic-able field exists (like created_by or lastedited_by)
and then apply the user id to one field or other one if it contains the
record id.

http://book.cakephp.org/2.0/en/models/behaviors.html

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: