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
var disqus_identifier = ‘xataface.com/wiki/fieldname__default’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘http://xataface.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })(); blog comments powered by Disqus
//<![CDATA[ (function() { var links = document.getElementsByTagName(‘a’); var query = ‘?’; for(var i = 0; i < links.length; i++) { if(links[i].href.indexOf(‘#disqus_thread’) >= 0) { query += ‘url’ + i + ‘=’ + encodeURIComponent(links[i].href) + ‘&’; } } document.write(‘