[ 'renderType' => 'resetSelection', ], ]; /** * Default field wizards enabled for this element. * * @var array */ protected $defaultFieldWizard = [ 'localizationStateSelector' => [ 'renderType' => 'localizationStateSelector', ], 'otherLanguageContent' => [ 'renderType' => 'otherLanguageContent', 'after' => [ 'localizationStateSelector', ], ], 'defaultLanguageDifferences' => [ 'renderType' => 'defaultLanguageDifferences', 'after' => [ 'otherLanguageContent', ], ], ]; /** * This will render a selector box element, or possibly a special construction with two selector boxes. * * @return array As defined in initializeResultArray() of AbstractNode */ public function render(): array { $languageService = $this->getLanguageService(); $resultArray = $this->initializeResultArray(); $parameterArray = $this->data['parameterArray']; // Field configuration from TCA: $config = $parameterArray['fieldConf']['config']; $selectItems = $parameterArray['fieldConf']['config']['items']; $disabled = !empty($config['readOnly']); // Get item value as array and make unique, which is fine because there can be no duplicates anyway. $itemArray = array_flip($parameterArray['itemFormElValue']); $width = $this->formMaxWidth($this->defaultInputWidth); $optionElements = []; foreach ($selectItems as $item) { $value = $item['value']; $attributes = []; // Selected or not by default if (isset($itemArray[$value])) { $attributes['selected'] = 'selected'; unset($itemArray[$value]); } // Non-selectable element if ((string)$value === '--div--') { $attributes['disabled'] = 'disabled'; $attributes['class'] = 'formcontrol-select-divider'; } $optionElements[] = $this->renderOptionElement($value, $item['label'], $attributes); } $selectItems = $parameterArray['fieldConf']['config']['items']; $size = (int)($config['size'] ?? 0); $autoSizeMax = (int)($config['autoSizeMax'] ?? 0); if ($autoSizeMax > 0) { $size = MathUtility::forceIntegerInRange($size, 1); $size = MathUtility::forceIntegerInRange(count($selectItems) + 1, $size, $autoSizeMax); } $selectId = StringUtility::getUniqueId($size === 1 ? 'tceforms-select' : 'tceforms-multiselect'); $selectElement = $this->renderSelectElement($optionElements, $parameterArray, $config, $selectId, $size); $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); $fieldControlResult = $this->renderFieldControl(); $fieldControlHtml = $fieldControlResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false); $fieldWizardResult = $this->renderFieldWizard(); $fieldWizardHtml = $fieldWizardResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false); $html = []; $html[] = $this->renderLabel($selectId); $html[] = '
'; $html[] = $fieldInformationHtml; $html[] = '
'; $html[] = '
'; $html[] = '
'; if (!$disabled) { // Add an empty hidden field which will send a blank value if all items are unselected. $html[] = ''; } $html[] = $selectElement; $html[] = '
'; if (!$disabled) { if (!empty($fieldControlHtml)) { $html[] = '
'; $html[] = $fieldControlHtml; $html[] = '
'; } $html[] = '
'; $html[] = '
'; $html[] = '' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.holdDownCTRL')) . ''; $html[] = '
'; if (!empty($fieldWizardHtml)) { $html[] = '
'; $html[] = $fieldWizardHtml; $html[] = '
'; } } else { $html[] = '
'; } $html[] = '
'; $html[] = ''; $resultArray['html'] = implode(LF, $html); return $resultArray; } /** * Renders a '; $html[] = implode(LF, $optionElements); $html[] = ''; return implode(LF, $html); } /** * Renders a single ', ]; return implode('', $html); } }