data['tableName']; $fieldName = $this->data['fieldName']; $parameterArray = $this->data['parameterArray']; $resultArray = $this->initializeResultArray(); $config = $parameterArray['fieldConf']['config']; $passwordPolicyValidator = null; $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); $passwordPolicy = $config['passwordPolicy'] ?? null; if ($passwordPolicy) { // We always use PasswordPolicyAction::NEW_USER_PASSWORD here, since the password is not set by the user, // but either by an admin or an editor $passwordPolicyValidator = GeneralUtility::makeInstance( PasswordPolicyValidator::class, PasswordPolicyAction::NEW_USER_PASSWORD, is_string($passwordPolicy) ? $passwordPolicy : '' ); } $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(); // Always add "trim" and "password" (required for JS validation) $evalList = ['trim', 'password']; if ($config['nullable'] ?? false) { $evalList[] = 'null'; } $attributes = [ 'value' => '', 'id' => $fieldId, 'spellcheck' => 'false', 'class' => implode(' ', [ 'form-control', 'form-control-clearable', 't3js-clearable', ]), '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']); } $attributes['autocomplete'] = ($config['autocomplete'] ?? false) ? 'current-password' : 'new-password'; $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[] = '
'; $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($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); } $passwordPolicyInfo = ''; if ($passwordPolicy) { $passwordPolicyInfo = $this->renderPasswordPolicyRequirements($passwordPolicyValidator, $fieldId); } $passwordElementAttributes['class'] = 'formengine-field-item t3js-formengine-field-item'; $passwordElementAttributes['recordFieldId'] = $fieldId; $passwordElementAttributes['passwordPolicy'] = $passwordPolicy; $resultArray['html'] = $renderedLabel . ' ' . $fieldInformationHtml . ' ' . $fullElement . ' ' . $passwordPolicyInfo . ' '; $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create( '@typo3/backend/form-engine/element/password-element.js' ); return $resultArray; } private function renderPasswordPolicyRequirements( PasswordPolicyValidator $passwordPolicyValidator, string $fieldId ): string { if (empty($passwordPolicyValidator->getRequirements())) { return ''; } $passwordPolicyElement = []; $requirements = []; foreach ($passwordPolicyValidator->getRequirements() as $id => $requirement) { $requirements[] = '
  • ' . $requirement . '
  • '; } $calloutTitle = $this->getLanguageService()->sL( 'LLL:EXT:core/Resources/Private/Language/locallang_password_policy.xlf:passwordRequirements.description' ); $passwordPolicyElement[] = ''; return implode(LF, $passwordPolicyElement); } /** * Obfuscated a (hashed) password secret with a static string. * * @todo * + server-side password obfuscation value is `*********` (9 chars) * + client-side password obfuscation value is `********` (8 chars) */ protected function getObfuscatedSecretValue(?string $value): string { if ($value === null || $value === '') { return ''; } return '*********'; } }