CMSMain - Fixed and enhanced BatchActionParameters

+ Fixed the $batchActions variable by making it use the `registeredActions()` method
+ Made the loop use `FieldHolder` instead of `Field` so CMS fields display correctly
+ Added hidden styles to the batch action div for jQuery show/hide functionality (found in Admin module PR)
This commit is contained in:
Benjamin Blake 2022-07-04 22:14:53 -06:00
parent d304ba9963
commit 81593057de

View File

@ -2114,23 +2114,23 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
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 .= "<div class=\"params\" id=\"BatchActionParameters_$urlSegment\">$html</div>\n\n";
$pageHtml .= "<div class=\"params\" id=\"BatchActionParameters_$urlSegment\" style=\"display:none\">$html</div>\n\n";
}
return new LiteralField("BatchActionParameters", '<div id="BatchActionParameters" style="display:none">'.$pageHtml.'</div>');
}