Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

siteConfig DataExtension not saving, no default values


Reply

2 Posts   346 Views

Avatar
Bimble

22 December 2013 at 3:59am (Last edited: 22 December 2013 4:00am), Community Member, 16 Posts

Hi, I am trying to extend DataExtension, but the default values are not being displayed and any values are not being saved to the DB.

<?php

class AnalyticsConfig extends DataExtension {

private static $db = array(
'redisIP' => 'varchar(250)',
'redisPort' => 'varchar(250)',
'redisSize' => 'varchar(250)',
);

public static $defaults = array(
'redisIP' => '127.0.0.1',
'redisPort' => '6379',
'redisSize' => '4832',
);

public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab("Root.Main", new TextField("RedisIP", "Redis IP"));
$fields->addFieldToTab("Root.Main", new TextField("RedisPort", "Redis Port"));
$fields->addFieldToTab("Root.Main", new TextField("RedisSize", "Redis Size"));
}

}

also, in _config.php i added

Object::add_extension('SiteConfig', 'AnalyticsConfig');

Any ideas?

Avatar
swaiba

24 December 2013 at 12:16am Forum Moderator, 1796 Posts

Hi,

Please see http://api.silverstripe.org/3.1/class-DataExtension.html

Alternatively if you are not using 3.1 then look for older documentation. Also look at several small modules as these often have great examples of exending the silverstripe datamodel