Commit 255e701d authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Properly handle readOnly in InputSlugElement

While the "readOnly" option is not supported
as columns config for type "slug", it might be
automatically set by FormEngine in case the
field is defined with "l10n_display", set to
"defaultAsReadonly".

This is now properly handled.

Resolves: #96096
Related: #89152
Releases: main, 11.5
Change-Id: I3ca0a6a17cc79704a727a6600b211833601dc290
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72318


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent b5379f4a
......@@ -97,6 +97,40 @@ class InputSlugElement extends AbstractFormElement
$fieldInformationHtml = $fieldInformationResult['html'];
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
// readOnly is not supported as columns config but might be set by SingleFieldContainer in case
// "l10n_display" is set to "defaultAsReadonly". To prevent misbehaviour for fields, which falsely
// set this, we also check for "defaultAsReadonly" being set and whether the record is an overlay.
if (($config['readOnly'] ?? false)
&& ($this->data['processedTca']['ctrl']['transOrigPointerField'] ?? false)
&& ($row[$this->data['processedTca']['ctrl']['transOrigPointerField']][0] ?? $row[$this->data['processedTca']['ctrl']['transOrigPointerField']] ?? false)
&& GeneralUtility::inList($parameterArray['fieldConf']['l10n_display'] ?? '', 'defaultAsReadonly')
) {
$disabledFieldAttributes = [
'class' => 'form-control',
'data-formengine-input-name' => $parameterArray['itemFormElName'],
'type' => 'text',
'value' => $itemValue,
'title' => $itemValue,
];
$html[] = '<div class="formengine-field-item t3js-formengine-field-item">';
$html[] = $fieldInformationHtml;
$html[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
$html[] = '<div class="form-wizards-wrap">';
$html[] = '<div class="form-wizards-element">';
$html[] = '<div class="input-group">';
$html[] = ($baseUrl ? '<span class="input-group-addon">' . htmlspecialchars($baseUrl) . '</span>' : '');
$html[] = '<input ' . GeneralUtility::implodeAttributes($disabledFieldAttributes, true) . ' disabled>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
$resultArray['html'] = implode(LF, $html);
return $resultArray;
}
$fieldControlResult = $this->renderFieldControl();
$fieldControlHtml = $fieldControlResult['html'];
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment