Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » siteConfig DataExtension not saving, no default values

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 311 Views
  • Bimble
    Avatar
    Community Member
    16 Posts

    siteConfig DataExtension not saving, no default values Link to this post

    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?

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: siteConfig DataExtension not saving, no default values Link to this post

    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

    311 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.