Jump to:

3449 Posts in 1063 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataExtension: Additional DB Fields are not saved

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

Page: 1
Go to End
Author Topic: 359 Views
  • plautzer
    Avatar
    Community Member
    7 Posts

    DataExtension: Additional DB Fields are not saved Link to this post

    Hi there,

    I have a simple sidebar extension for different page types.
    The SidebarContent field is shown in the admin but won't save any entries.
    I checked different examples, the documentation and this forum but I cannot find the problem.

    I am very grateful if one of you may help me out here

    class SideBarExtension extends DataExtension {

       static $db = array(
          'SidebarContent' => 'HTMLText'
       );

       public function updateCMSFields(FieldList $fields) {
          parent::updateCMSFields($fields);
    $fields->addFieldToTab("Root.Main", new HTMLEditorField('SidebarContent','Sidebar Content'));
       }

    }

  • plautzer
    Avatar
    Community Member
    7 Posts

    Re: DataExtension: Additional DB Fields are not saved Link to this post

    Here is one solution I just found out:

    Instead of configuring the extension in the config.yml

    e.g.

    StartPage:
    extensions:
    - 'SidebarExtension'

    I have to configure it in _config.php in order to make it work

    Object::add_extension('StartPage', 'SideBarExtension');

    Does anyone know why? It would be nice to have all the extension configurations in one file.

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: DataExtension: Additional DB Fields are not saved Link to this post

    Did you run "/dev/build/?flush" ?

    Also, I think "parent::updateCMSFields($fields);" is not necessary here since "parent" is an abstract class.

  • plautzer
    Avatar
    Community Member
    7 Posts

    Re: DataExtension: Additional DB Fields are not saved Link to this post

    I did build it couple of times. That shouldn't be the problem.

    Also if I don't put "parent::updateCMSFields($fields);" the new field will not be aligned with the other fields. It will look a bit off then.

    359 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.