Hello,
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 :
<?php
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 :
<?php
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',
array(
"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() {
parent::init();
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');
}
}
How can replace the only 'Save' button that appear in the popup with two buttons and there actions associated ?
Thank for your help,