--- SelectCheckBoxElement.php 2019-01-29 18:04:04.711144300 +0100 +++ SelectCheckBoxElement_new.php 2019-01-26 11:34:42.140624000 +0100 @@ -79,73 +79,73 @@ $selItems = $config['items']; if (!empty($selItems)) { // Get values in an array (and make unique, which is fine because there can be no duplicates anyway): + if ( is_string($parameterArray['itemFormElValue']) ) { + $parameterArray['itemFormElValue'] = explode(',', $parameterArray['itemFormElValue']); + } $itemArray = array_flip($parameterArray['itemFormElValue']); // Traverse the Array of selector box items: $groups = []; $currentGroup = 0; $c = 0; - $sOnChange = ''; - if (!$disabled) { - $sOnChange = implode('', $parameterArray['fieldChangeFunc']); - // Used to accumulate the JS needed to restore the original selection. - foreach ($selItems as $p) { - // Non-selectable element: - if ($p[1] === '--div--') { - $selIcon = ''; - if (isset($p[2]) && $p[2] !== 'empty-empty') { - $selIcon = FormEngineUtility::getIconHtml($p[2]); - } - $currentGroup++; - $groups[$currentGroup]['header'] = [ - 'icon' => $selIcon, - 'title' => $p[0] - ]; - } else { - // Check if some help text is available - // Help text is expected to be an associative array - // with two key, "title" and "description" - // For the sake of backwards compatibility, we test if the help text - // is a string and use it as a description (this could happen if items - // are modified with an itemProcFunc) - $hasHelp = false; - $help = ''; - $helpArray = []; - if (!empty($p[3])) { - $hasHelp = true; - if (is_array($p[3])) { - $helpArray = $p[3]; - } else { - $helpArray['description'] = $p[3]; - } - } - if ($hasHelp) { - $help = BackendUtility::wrapInHelp('', '', '', $helpArray); - } - - // Selected or not by default: - $checked = 0; - if (isset($itemArray[$p[1]])) { - $checked = 1; - unset($itemArray[$p[1]]); - } - - // Build item array - $groups[$currentGroup]['items'][] = [ - 'id' => StringUtility::getUniqueId('select_checkbox_row_'), - 'name' => $parameterArray['itemFormElName'] . '[' . $c . ']', - 'value' => $p[1], - 'checked' => $checked, - 'disabled' => false, - 'class' => '', - 'icon' => FormEngineUtility::getIconHtml(!empty($p[2]) ? $p[2] : 'empty-empty'), - 'title' => $p[0], - 'help' => $help - ]; - $c++; - } - } - } + $sOnChange = implode('', $parameterArray['fieldChangeFunc']); + // Used to accumulate the JS needed to restore the original selection. + foreach ($selItems as $p) { + // Non-selectable element: + if ($p[1] === '--div--') { + $selIcon = ''; + if (isset($p[2]) && $p[2] !== 'empty-empty') { + $selIcon = FormEngineUtility::getIconHtml($p[2]); + } + $currentGroup++; + $groups[$currentGroup]['header'] = [ + 'icon' => $selIcon, + 'title' => $p[0] + ]; + } else { + // Check if some help text is available + // Help text is expected to be an associative array + // with two key, "title" and "description" + // For the sake of backwards compatibility, we test if the help text + // is a string and use it as a description (this could happen if items + // are modified with an itemProcFunc) + $hasHelp = false; + $help = ''; + $helpArray = []; + if (!empty($p[3])) { + $hasHelp = true; + if (is_array($p[3])) { + $helpArray = $p[3]; + } else { + $helpArray['description'] = $p[3]; + } + } + if ($hasHelp) { + $help = BackendUtility::wrapInHelp('', '', '', $helpArray); + } + + // Selected or not by default: + $checked = 0; + if (isset($itemArray[$p[1]])) { + $checked = 1; + unset($itemArray[$p[1]]); + } + + // Build item array + $groups[$currentGroup]['items'][] = [ + 'id' => StringUtility::getUniqueId('select_checkbox_row_'), + 'name' => $parameterArray['itemFormElName'] . '[' . $c . ']', + 'value' => $p[1], + 'checked' => $checked, + 'disabled' => $disabled, + 'class' => '', + 'icon' => FormEngineUtility::getIconHtml(!empty($p[2]) ? $p[2] : 'empty-empty'), + 'title' => $p[0], + 'help' => $help + ]; + $c++; + } + } $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; @@ -204,7 +204,7 @@ // Build reset group button $resetGroupBtn = ''; - if (!empty($resetGroup)) { + if (!empty($resetGroup) && !$disabled) { $resetGroup[] = 'TYPO3.FormEngine.updateCheckboxState(this);'; $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.revertSelection')); $resetGroupBtn = ''; } $checkboxId = uniqid($groupId); + $checkbox = ''; + $checkboxLabel = ' '; + if (!$disabled) { + $checkbox = ''; + $checkboxLabel = ''; + } $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall')); $html[] = '
'; $html[] = ''; $html[] = ''; $html[] = ''; - $html[] = ''; - $html[] = ''; + $html[] = ''; + $html[] = ''; $html[] = ''; $html[] = ''; $html[] = '';
'; - $html[] = ''; - $html[] = '' . $checkbox . '' . $checkboxLabel . '' . $resetGroupBtn . '