Hi Markus,
Thanks for the question.Ê There are a couple of ways to accomplish this.Ê You can either set the default field value to the user id, or you can set the value in the beforeSave() trigger.
I generally prefer the first method.Ê For this, you would use the fieldname__default() method in the delegate class:
e.g.Ê Suppose the name of the field we want to populate is username:
function username__default(){
ÊÊÊ $auth =& Dataface_AuthenticationTool::getInstance();
ÊÊÊ return $auth->getLoggedInUsername();
}
Then it is a good idea to set the widget for this field to hidden so that it can't be changed (or make it so that only administrators have edit permissions for this field).
The second option (setting it in the beforeSave() trigger) would look like:
function beforeSave(&$record){
ÊÊÊ $auth =& Dataface_AuthenticationTool::getInstance();
ÊÊÊ $record->setValue('username', $auth->getLoggedInUsername());
}
(Note that the beforeSave() trigger will only work for this in 0.7 and later.Ê In 0.6.x changes made to the record in the triggers weren't propogated to the database).
Hope this helps.
-Steve