diff --git a/_config/config.yml b/_config/config.yml index c480278a..47a76215 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -4,6 +4,7 @@ Name: cmsextensions SilverStripe\Admin\LeftAndMain: extensions: - SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension + - SilverStripe\CMS\Controllers\LeftAndMainBatchActionsExtension --- Name: cmsmodals --- diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index db715788..df619ea8 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -2112,28 +2112,38 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return new CMSBatchActionHandler($this, 'batchactions'); } + /** + * Returns a LiteralField containing parameter field HTML + * for batch actions + * + * Used by {@link LeftAndMain} to render batch actions in + * the BatchActionsForm + * + * @return LiteralField + */ public function BatchActionParameters() { - $batchActions = CMSBatchActionHandler::config()->batch_actions; + $batchActions = $this->batchactions()->registeredActions(); $forms = []; foreach ($batchActions as $urlSegment => $batchAction) { - $SNG_action = singleton($batchAction); - if ($SNG_action->canView() && $fieldset = $SNG_action->getParameterFields()) { + $SNG_action = singleton($batchAction['class']); + if ($SNG_action->canView() && $fieldList = $SNG_action->getParameterFields()) { $formHtml = ''; /** @var FormField $field */ - foreach ($fieldset as $field) { - $formHtml .= $field->Field(); + foreach ($fieldList as $field) { + $formHtml .= $field->FieldHolder(); } $forms[$urlSegment] = $formHtml; } } $pageHtml = ''; foreach ($forms as $urlSegment => $html) { - $pageHtml .= "
$html
\n\n"; + $pageHtml .= ''; } - return new LiteralField("BatchActionParameters", ''); + return new LiteralField('BatchActionParameters', ''); } + /** * Returns a list of batch actions */ diff --git a/code/Controllers/LeftAndMainBatchActionsExtension.php b/code/Controllers/LeftAndMainBatchActionsExtension.php new file mode 100644 index 00000000..8e582972 --- /dev/null +++ b/code/Controllers/LeftAndMainBatchActionsExtension.php @@ -0,0 +1,16 @@ +Fields()->insertAfter('Action', $cmsMain->BatchActionParameters()); + return $form; + } +}