diff --git a/_config/config.yml b/_config/config.yml index c480278a85..47a7621559 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 db715788fd..df619ea8d0 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -2112,28 +2112,38 @@ public function batchactions() 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 0000000000..8e582972e3 --- /dev/null +++ b/code/Controllers/LeftAndMainBatchActionsExtension.php @@ -0,0 +1,16 @@ +Fields()->insertAfter('Action', $cmsMain->BatchActionParameters()); + return $form; + } +}