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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

DataExtension: Additional DB Fields are not saved


Go to End


4 Posts   2152 Views

Avatar
plautzer

Community Member, 10 Posts

25 March 2014 at 1:29am

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

Community Member, 10 Posts

25 March 2014 at 5:02am

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

Community Member, 344 Posts

25 March 2014 at 5:02am

Edited: 25/03/2014 5:10am

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

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

Avatar
plautzer

Community Member, 10 Posts

25 March 2014 at 3:02pm

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.