[ 'renderType' => 'localizationStateSelector', ], 'otherLanguageContent' => [ 'renderType' => 'otherLanguageContent', 'after' => [ 'localizationStateSelector', ], ], 'defaultLanguageDifferences' => [ 'renderType' => 'defaultLanguageDifferences', 'after' => [ 'otherLanguageContent', ], ], ]; /** * This will render a single-line email form field, possibly with various control/validation features * * @return array As defined in initializeResultArray() of AbstractNode */ public function render(): array { $table = $this->data['tableName']; $fieldName = $this->data['fieldName']; $parameterArray = $this->data['parameterArray']; $resultArray = $this->initializeResultArray(); $config = $parameterArray['fieldConf']['config']; $itemValue = $parameterArray['itemFormElValue']; $width = $this->formMaxWidth( MathUtility::forceIntegerInRange($config['size'] ?? $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth) ); $fieldId = StringUtility::getUniqueId('formengine-input-'); $itemName = (string)$parameterArray['itemFormElName']; $renderedLabel = $this->renderLabel($fieldId); $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); if ($config['readOnly'] ?? false) { $html = []; $html[] = $renderedLabel; $html[] = '
'; $html[] = $fieldInformationHtml; $html[] = '
'; $html[] = '
'; $html[] = '
'; $html[] = ''; $html[] = '
'; $html[] = '
'; $html[] = '
'; $html[] = '
'; $resultArray['html'] = implode(LF, $html); return $resultArray; } $languageService = $this->getLanguageService(); // Get filtered eval list, while always adding "trim" $evalList = array_merge(array_filter( GeneralUtility::trimExplode(',', $config['eval'] ?? '', true), static fn(string $value): bool => in_array($value, ['unique', 'uniqueInPid'], true) ), ['trim']); if ($config['nullable'] ?? false) { $evalList[] = 'null'; } $attributes = [ 'value' => '', 'id' => $fieldId, 'maxlength' => '254', 'data-formengine-validation-rules' => $this->getValidationDataAsJsonString($config), 'data-formengine-input-params' => (string)json_encode([ 'field' => $itemName, 'evalList' => implode(',', $evalList), ], JSON_THROW_ON_ERROR), 'data-formengine-input-name' => $itemName, ]; if (!empty($config['placeholder'])) { $attributes['placeholder'] = trim($config['placeholder']); } if (isset($config['autocomplete'])) { $attributes['autocomplete'] = empty($config['autocomplete']) ? 'new-' . $fieldName : 'on'; } $fieldControlResult = $this->renderFieldControl(); $fieldControlHtml = $fieldControlResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false); $fieldWizardResult = $this->renderFieldWizard(); $fieldWizardHtml = $fieldWizardResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false); $mainFieldHtml = []; $mainFieldHtml[] = '
'; $mainFieldHtml[] = '
'; $mainFieldHtml[] = '
'; if (is_array($config['valuePicker']['items'] ?? false)) { $attributes['class'] = 'form-control'; $mainFieldHtml[] = ''; $mainFieldHtml[] = ''; foreach ($config['valuePicker']['items'] as $item) { $mainFieldHtml[] = '' . htmlspecialchars($languageService->sL($item['label'])) . ''; } $mainFieldHtml[] = ''; $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/backend/element/combobox-element.js'); } else { $attributes['class'] = implode(' ', [ 'form-control', 'form-control-clearable', 't3js-clearable', ]); $mainFieldHtml[] = ''; } $mainFieldHtml[] = ''; $mainFieldHtml[] = '
'; if (!empty($fieldControlHtml)) { $mainFieldHtml[] = '
'; $mainFieldHtml[] = '
'; $mainFieldHtml[] = $fieldControlHtml; $mainFieldHtml[] = '
'; $mainFieldHtml[] = '
'; } if (!empty($fieldWizardHtml)) { $mainFieldHtml[] = '
'; $mainFieldHtml[] = $fieldWizardHtml; $mainFieldHtml[] = '
'; } $mainFieldHtml[] = '
'; $mainFieldHtml[] = '
'; $mainFieldHtml = implode(LF, $mainFieldHtml); $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $this->data['databaseRow']['uid'] . '][' . $fieldName . ']'); $fullElement = $mainFieldHtml; if ($this->hasNullCheckboxButNoPlaceholder()) { $checked = $itemValue !== null ? ' checked="checked"' : ''; $fullElement = []; $fullElement[] = '
'; $fullElement[] = '
'; $fullElement[] = ''; $fullElement[] = ''; $fullElement[] = ''; $fullElement[] = '
'; $fullElement[] = $mainFieldHtml; $fullElement = implode(LF, $fullElement); } elseif ($this->hasNullCheckboxWithPlaceholder()) { $checked = $itemValue !== null ? ' checked="checked"' : ''; $placeholder = $shortenedPlaceholder = trim((string)($config['placeholder'] ?? '')); if ($placeholder !== '') { $shortenedPlaceholder = GeneralUtility::fixed_lgd_cs($placeholder, 20); if ($placeholder !== $shortenedPlaceholder) { $overrideLabel = sprintf( $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override'), '' . htmlspecialchars($shortenedPlaceholder) . '' ); } else { $overrideLabel = sprintf( $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override'), htmlspecialchars($placeholder) ); } } else { $overrideLabel = $languageService->sL( 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override_not_available' ); } $fullElement = []; $fullElement[] = '
'; $fullElement[] = ''; $fullElement[] = ''; $fullElement[] = ''; $fullElement[] = '
'; $fullElement[] = '
'; $fullElement[] = '
'; $fullElement[] = ''; $fullElement[] = '
'; $fullElement[] = '
'; $fullElement[] = '
'; $fullElement[] = $mainFieldHtml; $fullElement[] = '
'; $fullElement = implode(LF, $fullElement); } $resultArray['html'] = $renderedLabel . '
' . $fieldInformationHtml . $fullElement . '
'; return $resultArray; } }