Adding logged on user to a record

A place for users and developers of the Xataface to discuss and receive support.

Adding logged on user to a record

Postby ngms27 » Thu Jan 10, 2013 7:41 am

I have a table Projects which has a 1 to many relationship with Notes.
I'd like to be able to add the logged on user to a field in Notes every time a new notes record is added.

i.e. Notes structure is currently

id
project_id
details

I'd change it to

id
project_id
details
user
ngms27
 
Posts: 30
Joined: Mon Nov 12, 2012 8:18 am

Re: Adding logged on user to a record

Postby shannah » Thu Jan 10, 2013 10:27 am

Use beforeSave() or beforeInsert().

Code: Select all
function beforeSave(Dataface_Record $record){
    $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
    $record->setValue('user', $username);
}
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Adding logged on user to a record

Postby ngms27 » Fri Jan 11, 2013 6:19 am

Worked great thank you.
ngms27
 
Posts: 30
Joined: Mon Nov 12, 2012 8:18 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved