[ 'renderType' => 'tcaDescription', ], ]; /** * Default field wizards enabled for this element. * * @var array */ protected $defaultFieldWizard = [ 'selectIcons' => [ 'renderType' => 'selectIcons', 'disabled' => true, ], 'localizationStateSelector' => [ 'renderType' => 'localizationStateSelector', 'after' => [ 'selectIcons', ], ], 'otherLanguageContent' => [ 'renderType' => 'otherLanguageContent', 'after' => [ 'localizationStateSelector' ], ], 'defaultLanguageDifferences' => [ 'renderType' => 'defaultLanguageDifferences', 'after' => [ 'otherLanguageContent' ], ], ]; /** * Render single element * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $resultArray = $this->initializeResultArray(); $table = $this->data['tableName']; $field = $this->data['fieldName']; $parameterArray = $this->data['parameterArray']; $config = $parameterArray['fieldConf']['config']; $selectItems = $parameterArray['fieldConf']['config']['items']; $classList = ['form-select', 'form-control-adapt']; // Check against inline uniqueness /** @var InlineStackProcessor $inlineStackProcessor */ $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class); $inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']); $uniqueIds = null; if ($this->data['isInlineChild'] && $this->data['inlineParentUid']) { // @todo: At least parts of this if is dead and/or broken: $uniqueIds is filled but never used. // See InlineControlContainer where 'inlineData' 'unique' 'used' is set. What exactly is // this if supposed to do and when should it kick in and what for? $inlineObjectName = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']); if ($this->data['inlineParentConfig']['foreign_table'] === $table && $this->data['inlineParentConfig']['foreign_unique'] === $field ) { $classList[] = 't3js-inline-unique'; $uniqueIds = $this->data['inlineData']['unique'][$inlineObjectName . '-' . $table]['used']; } // hide uid of parent record for symmetric relations if ($this->data['inlineParentConfig']['foreign_table'] === $table && ( $this->data['inlineParentConfig']['foreign_field'] === $field || $this->data['inlineParentConfig']['symmetric_field'] === $field ) ) { $uniqueIds[] = $this->data['inlineParentUid']; } } // Initialization: $selectId = StringUtility::getUniqueId('tceforms-select-'); $selectedIcon = ''; $size = (int)$config['size']; // Style set on $options = ''; $disabled = false; if (!empty($config['readOnly'])) { $disabled = true; } // Prepare groups $selectItemCounter = 0; $selectItemGroupCount = 0; $selectItemGroups = []; $selectedValue = ''; $hasIcons = false; // In case e.g. "l10n_display" is set to "defaultAsReadonly" only one value (as string) could be handed in if (!empty($parameterArray['itemFormElValue'])) { if (is_array($parameterArray['itemFormElValue'])) { $selectedValue = (string)$parameterArray['itemFormElValue'][0]; } else { $selectedValue = (string)$parameterArray['itemFormElValue']; } } foreach ($selectItems as $item) { if ($item[1] === '--div--') { // IS OPTGROUP if ($selectItemCounter !== 0) { $selectItemGroupCount++; } $selectItemGroups[$selectItemGroupCount]['header'] = [ 'title' => $item[0], ]; } else { // IS ITEM $icon = !empty($item[2]) ? FormEngineUtility::getIconHtml($item[2], $item[0], $item[0]) : ''; $selected = $selectedValue === (string)$item[1]; if ($selected) { $selectedIcon = $icon; } $selectItemGroups[$selectItemGroupCount]['items'][] = [ 'title' => $this->appendValueToLabelInDebugMode($item[0], $item[1]), 'value' => $item[1], 'icon' => $icon, 'selected' => $selected, ]; $selectItemCounter++; } } // Fallback icon // @todo: assign a special icon for non matching values? if (!$selectedIcon && $selectItemGroups[0]['items'][0]['icon']) { $selectedIcon = $selectItemGroups[0]['items'][0]['icon']; } // Process groups foreach ($selectItemGroups as $selectItemGroup) { // suppress groups without items if (empty($selectItemGroup['items'])) { continue; } $optionGroup = is_array($selectItemGroup['header']); $options .= ($optionGroup ? '' : ''); } $selectAttributes = [ 'id' => $selectId, 'name' => (string)($parameterArray['itemFormElName'] ?? ''), 'data-formengine-validation-rules' => $this->getValidationDataAsJsonString($config), 'class' => implode(' ', $classList), ]; if ($size) { $selectAttributes['size'] = (string)$size; } if ($disabled) { $selectAttributes['disabled'] = 'disabled'; } $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[] = '