I have a field that uses the Username for the DB. How can I have the field on the Add section have an initial value of the person's user name? I've looked around and can't seem to find something that has been addressed like this before. Thanks for any help!
Feb 20, 2006, 7:00 PM
Veteran / Moderator (8669 posts)
Feb 20, 2006, 7:00 PM
Post #2 of 2
Views: 516
Funny you should ask. I just was thinking about that today and wrote a little mod for it.
First, you need to set the $auth_user_field in your .cfg file to the number of the field where your userid is.
Then, in db.cgi, sub get_defaults, after
my (%default);
add
$user_field_name = $db_cols[$auth_user_field];
$default{$user_field_name} = $db_userid;
}
As the script is written, it will add the userid at the time the record is actually added to the database, but I think it's nice to see it in the field.
JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
First, you need to set the $auth_user_field in your .cfg file to the number of the field where your userid is.
Then, in db.cgi, sub get_defaults, after
my (%default);
add
Code:
if ($auth_user_field >= 0) { $user_field_name = $db_cols[$auth_user_field];
$default{$user_field_name} = $db_userid;
}
As the script is written, it will add the userid at the time the record is actually added to the database, but I think it's nice to see it in the field.
JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

