[ 'renderType' => 'elementBrowser', ], ]; /** * Default field wizards for this element * * @var array */ protected $defaultFieldWizard = [ 'localizationStateSelector' => [ 'renderType' => 'localizationStateSelector', 'after' => [ 'recordsOverview' ], ], 'otherLanguageContent' => [ 'renderType' => 'otherLanguageContent', 'after' => [ 'localizationStateSelector' ], ], 'defaultLanguageDifferences' => [ 'renderType' => 'defaultLanguageDifferences', 'after' => [ 'otherLanguageContent' ], ], ]; public function __construct( private readonly IconFactory $iconFactory, ) {} /** * This will render a selector box into which folder relations can be * inserted. * * @return array As defined in initializeResultArray() of AbstractNode * @throws \RuntimeException */ public function render(): array { $languageService = $this->getLanguageService(); $resultArray = $this->initializeResultArray(); $row = $this->data['databaseRow']; $parameterArray = $this->data['parameterArray']; $config = $parameterArray['fieldConf']['config']; $elementName = $parameterArray['itemFormElName']; $selectedItems = $parameterArray['itemFormElValue']; $maxItems = $config['maxitems']; $size = (int)($config['size'] ?? 5); $autoSizeMax = (int)($config['autoSizeMax'] ?? 0); if ($autoSizeMax > 0) { $size = MathUtility::forceIntegerInRange($size, 1); $size = MathUtility::forceIntegerInRange(count($selectedItems) + 1, $size, $autoSizeMax); } $fieldId = StringUtility::getUniqueId('tceforms-multiselect-'); $listOfSelectedValues = []; $selectorOptionsHtml = []; foreach ($selectedItems as $selectedItem) { $folder = $selectedItem['folder']; $listOfSelectedValues[] = $folder; $selectorOptionsHtml[] = ''; } $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); if (isset($config['readOnly']) && $config['readOnly']) { // Return early if element is read only $html = []; $html[] = $this->renderLabel($fieldId); $html[] = '
'; $html[] = $fieldInformationHtml; $html[] = '
'; $html[] = '
'; $html[] = ' $fieldId, 'data-formengine-input-name' => htmlspecialchars($elementName), 'data-maxitems' => (string)$maxItems, 'size' => (string)$size, ]; $selectorAttributes['class'] = 'form-select'; if ($maxItems !== 1 && $size !== 1) { $selectorAttributes['multiple'] = 'multiple'; } $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($fieldId); $html[] = '
'; $html[] = $fieldInformationHtml; $html[] = '
'; $html[] = '
'; $html[] = ''; $html[] = ''; $html[] = '
'; if (($maxItems > 1 && $size > 1 && $showMoveIcons) || $showDeleteControl) { $html[] = '
'; $html[] = '
'; if ($maxItems > 1 && $size >= 2 && $showMoveIcons) { $html[] = ''; } if ($maxItems > 1 && $size > 1 && $showMoveIcons) { $html[] = ''; $html[] = ''; } if ($maxItems > 1 && $size >= 2 && $showMoveIcons) { $html[] = ''; } if ($showDeleteControl) { $html[] = ''; } $html[] = '
'; $html[] = '
'; } if ($fieldControlHtml !== '') { $html[] = '
'; $html[] = '
'; $html[] = $fieldControlHtml; $html[] = '
'; $html[] = '
'; } if (!empty($fieldWizardHtml)) { $html[] = '
'; $html[] = $fieldWizardHtml; $html[] = '
'; } $html[] = '
'; $hiddenElementAttrs = array_merge( [ 'type' => 'hidden', 'name' => $elementName, 'data-formengine-validation-rules' => $this->getValidationDataAsJsonString($config), 'value' => implode(',', $listOfSelectedValues), ], $this->getOnFieldChangeAttrs('change', $parameterArray['fieldChangeFunc'] ?? []) ); $html[] = ''; $html[] = '
'; $resultArray['html'] = ' ' . implode(LF, $html) . ' '; $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/backend/form-engine/element/folder-element.js'); return $resultArray; } }