fieldname__default Delegate Class Method
Return to Delegate class methods
Synopsis
Xataface allows you to pre-populate any particular field in a table by adding a fieldname__default method to the table’s delegate class of the form:
function fieldname__default(){
return value;
}
Returns the default value for the field fieldname. New record forms will be prepopulated with this value.
Examples
function minimum_bid__default(){
return 100;
}
function mydatecol__default(){
return date('Y-m-d');
}
function owner_id__default(){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( isset($user) ) return $user->val('userid');
return null;
}
See Also
- Pre-entered Data (forum thread) - setting defaults field values on general fields using the fieldname__default delegate class function
- How to initialize a Date field to today’s date? (forum thread) - alternate methods to use specifically with a date/time field
- Setting default select setting from users table (forum thread) - solution to populate the current user