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.

Customising the CMS /

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

DataExtension for all Classes inherting from page,... checkboxfield does not save


Go to End


3 Posts   954 Views

Avatar
Lukin

Community Member, 56 Posts

28 December 2014 at 11:14am

Hi,

I writing an extension which has to be available for all subclassess of page and page itself. So in that s the way I extend the page class:Object::add_extension('Page', 'ProductExtension');

ProducExtension has a db-field (buyable=>Boolean)

with updateCMSFields I add a checkbox field to the field list. It's now displayed in every subclass of page. But I can not save it.
Extending the subclasses too is working if i do not extend class page...

any sugestions? thx in advance

Avatar
camfindlay

Forum Moderator, 267 Posts

28 December 2014 at 12:00pm

Can you post your extension code (remove or generalise anything sensitive of course)?

Avatar
Lukin

Community Member, 56 Posts

29 December 2014 at 7:50pm

Edited: 29/12/2014 7:51pm

hej,

that's the generalized code, the many_many relation is working fine...

class ProductExtension extends DataExtension {

	private static $db=array(
		'Byable'=>'Boolean'
	);
	private static $many_many=array(
		'OptionSets'=>'OptionSet'
	);
	public function updateCMSFields(FieldList $fields) {
		$gridFieldConfig = GridFieldConfig_RecordEditor ::create()->addComponents(
			new GridFieldOrderableRows('SortID')
	  	);
		$optionSetsGridField = new GridField("OptionSets", "OptionSets", $this->owner->OptionSets()->sort('SortID'), $gridFieldConfig);
		$fields->addFieldToTab('Root.Shop',new CheckboxField('Buyable','Verkaufbar'));
		$fields->addFieldToTab('Root.Shop',$optionSetsGridField);
   	}
}