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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjectManager and Versioned

Go to End

3 Posts   1076 Views


Community Member, 70 Posts

26 November 2010 at 5:51am


I would like to manage versioned dataobjects (named "Product"s in my code) with DataObjectManager and have 2 actions boutons 'Save' and 'Save & publish' (like Sitetree objects in CMS) in popups generated by DataObjectManager.

My Product class code is :


class Product extends DataObject {
	static $db = array(
		'Name' => 'Text',
		'Description' => 'HTMLText',

	static $has_one = array(
		'Page' => 'Page',

	static $extensions = array(
		"Versioned('Stage', 'Live')"

	function getCMSfields() {
		$fields = new FieldSet(
			new TextField('Name', _t('Product.Name', 'Name')),
			new SimpleHtmlEditorField('Description', _t('Product.Description', 'Description'))

		return $fields;



And for example, my Page class code where i use DataObjectManager :

class Page extends SiteTree {

	public static $db = array();

	public static $has_one  = array();
	public static $has_many = array( 'Products' => 'Product' );

	function getCMSFields() {
		$fields = parent::getCMSFields();

		$productsTable = new DataObjectManager(
			$this, _t('Product.PLURALNAME', 'Products'), 'Product',
				"Name"            => _t('Product.Name', 'Name'),
				"Description"     => _t('Product.Description', 'Description'),
		$productsTable->setAddTitle( _t('Product.SINGULARNAME', 'Product'));

		$fields->addFieldToTab('Root.Content.Products', $productsTable);
		$fields->findOrMakeTab('Root.Content.Products')->setTitle( _t('Product.PLURALNAME', 'Products'));

		return $fields;


class Page_Controller extends ContentController {

	public static $allowed_actions = array ( );

	public function init() {

How can replace the only 'Save' button that appear in the popup with two buttons and there actions associated ?

Thank for your help,


Community Member, 70 Posts

4 December 2010 at 3:00am

Perhaps my question isn't clear ?.. :'(


Forum Moderator, 4102 Posts

4 December 2010 at 5:06am

Generally, the way this is done is to overload the publish/unpublish functions on your parent page, and have those cascade down to the related objects in the DOM.

See the UserDefinedForm module for an example. When the UDF page is published/unpublished, it cuts new versions of the associated form elements.

SilverStripe tips, tutorials, screencasts and more: