protected function getFormActions()
 {
     $actions = parent::getFormActions();
     // Check if record is versionable
     /** @var Versioned|DataObject $record */
     $record = $this->getRecord();
     if (!$record || !$record->has_extension('SilverStripe\\ORM\\Versioning\\Versioned')) {
         return $actions;
     }
     // Save & Publish action
     if ($record->canPublish()) {
         // "publish", as with "save", it supports an alternate state to show when action is needed.
         $publish = FormAction::create('doPublish', _t('VersionedGridFieldItemRequest.BUTTONPUBLISH', 'Publish'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
         // Insert after save
         if ($actions->fieldByName('action_doSave')) {
             $actions->insertAfter('action_doSave', $publish);
         } else {
             $actions->push($publish);
         }
     }
     // Unpublish action
     $isPublished = $record->isPublished();
     if ($isPublished && $record->canUnpublish()) {
         $actions->push(FormAction::create('doUnpublish', _t('VersionedGridFieldItemRequest.BUTTONUNPUBLISH', 'Unpublish'))->setUseButtonTag(true)->setDescription(_t('VersionedGridFieldItemRequest.BUTTONUNPUBLISHDESC', 'Remove this record from the published site'))->addExtraClass('ss-ui-action-destructive'));
     }
     // Archive action
     if ($record->canArchive()) {
         // Replace "delete" action
         $actions->removeByName('action_doDelete');
         // "archive"
         $actions->push(FormAction::create('doArchive', _t('VersionedGridFieldItemRequest.ARCHIVE', 'Archive'))->setDescription(_t('VersionedGridFieldItemRequest.BUTTONARCHIVEDESC', 'Unpublish and send to archive'))->addExtraClass('delete ss-ui-action-destructive'));
     }
     return $actions;
 }
 public function testItemEditFormCallback()
 {
     $this->logInWithPermission('ADMIN');
     $category = new GridFieldDetailFormTest_Category();
     $component = new GridFieldDetailForm();
     $component->setItemEditFormCallback(function ($form, $component) {
         $form->Fields()->push(new HiddenField('Callback'));
     });
     // Note: A lot of scaffolding to execute the tested logic,
     // due to the coupling of form creation with request handling (and its context)
     /** @skipUpgrade */
     $request = new GridFieldDetailForm_ItemRequest(GridField::create('Categories', 'Categories'), $component, $category, new Controller(), 'Form');
     $form = $request->ItemEditForm();
     $this->assertNotNull($form->Fields()->fieldByName('Callback'));
 }