21492 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 840 Views |
-
Default values for SiteConfig extension

9 December 2010 at 10:57pm
Hi
Does anyone know how to set default values for the site config fields ... similar to:
static $defaults = array (...);
for DataObjects?
I tried using static $defaults in my SiteConfig extension but the values didn't get set.
class CustomSiteConfig extends DataObjectDecorator {
/**
* Defines the additional site configuration fields
*
* @return array
*/
function extraStatics() {
return array(
'db' => array(
'IsDisplayTestAskUs' => 'Boolean'
, 'IsDisplayFooterHoncode' => 'Boolean'
),
}/**
* Displays the edit fields in the CMS
*
* @param FieldSet $fields
*/
public function updateCMSFields( $fields ) {
$fields->addFieldToTab( 'Root.Main', new CheckboxField( 'IsDisplayTestAskUs', 'Display Test Ask Us') );
$fields->addFieldToTab( 'Root.Main', new CheckboxField( 'IsDisplayFooterHoncode', 'Display Footer HON code') );
}// not sure if this will work with SiteConfig fields
static $defaults = array (
'IsDisplayTestAskUs' => true
, 'IsDisplayFooterHoncode' => true
);
}Thanks!
-
Re: Default values for SiteConfig extension

10 December 2010 at 12:14pm
Because you are dealing with an extension (i.e the SiteConfig::$defaults won't call your static) you need to use the extension class extraStatics (like you have) and include the defaults there.
function extraStatics() {
return array(
'db' => array(
'IsDisplayTestAskUs' => 'Boolean' ,
'IsDisplayFooterHoncode' => 'Boolean'
),
'defaults' => array(
'IsDisplayTestAskUs' => true
));
} -
Re: Default values for SiteConfig extension

10 December 2010 at 12:37pm
Thanks Willr! That did the trick.
| 840 Views | ||
|
Page:
1
|
Go to Top |


