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

DataExtension: Additional DB Fields are not saved


Reply

4 Posts   382 Views

Avatar
plautzer

25 March 2014 at 1:29am Community Member, 7 Posts

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'));
   }

}

Avatar
plautzer

25 March 2014 at 5:02am Community Member, 7 Posts

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.

Avatar
Devlin

25 March 2014 at 5:02am (Last edited: 25 March 2014 5:10am), Community Member, 215 Posts

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

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

Avatar
plautzer

25 March 2014 at 3:02pm Community Member, 7 Posts

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.