I am trying to add a copy dataobject button next to the save and delete button on a dataobject but "getCMSActions" does not seem to work.
I have followed the tutorials on the following pages:
But both did not solve my problem my code currently looks like this.
public function getCMSActions() {
$actions = parent::getCMSActions();
if ($this->ID) {
$actions->push(FormAction::create('copy', _t('SiteBlockAdmin.Copy', 'Copy'))
->setUseButtonTag(true)
->setAttribute('data-icon', 'arrow-circle-double'));
$actions->push(DropdownField::create('BegrotingsPageCopyToID', '', BegrotingsPage::get()->map())
->setEmptyString('Selecteer pagina voor kopie'));
}
return $actions;
}
What I want to achieve is to make the copy button and dropdownfield show up next to the save and delete button with the getCMSActions field.
The problem is that
GridFieldDetailForm_ItemRequest::getFormActions()doesn't call$this->record->getCMSActions(), instead it defines its initial list of actions as$actions = new FieldList();.I assume you're managing your DataObject via a ModelAdmin.
You can add an extension to this class and add the fields that way (but it's sub-optimal):
And your extension could look like this:
I've also raised an issue to follow up on the misleading documentation: https://github.com/silverstripe/silverstripe-framework/issues/8773