Skip to content
Snippets Groups Projects
Commit 85b00d0d authored by Andreas Kienast's avatar Andreas Kienast Committed by Oliver Bartsch
Browse files

[TASK] Do not render `typo3-formengine-updater` if linked field is hidden

TYPO3's TCA type field is rendered in the FormEngine along with a
`<typo3-formengine-updater>` element that listens on changes on the
linked type field.

This is a rare case: if FormEngine is programmatically rendered via an
own controller and the value of the `type` field is hardcoded via
`overrideValues` in the FormEngine compiler, the field itself is not rendered.

However, the `<typo3-formengine-updater>` element is still there,
leaving an "empty" field group.

This patch now checks whether something is available for rendering
before rendering the `<typo3-formengine-updater>` element.

Resolves: #103449
Releases: main
Change-Id: I708b49665dfaa5b836954e40e99cbcb9ed44ec03
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83554


Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarBenjamin Franzke <ben@bnf.dev>
Reviewed-by: default avatarBenjamin Franzke <ben@bnf.dev>
parent a0905631
Branches
Tags
No related merge requests found
......@@ -130,18 +130,19 @@ class SingleFieldContainer extends AbstractContainer
$options['renderType'] = $parameterArray['fieldConf']['config']['type'];
}
$resultArray = $this->nodeFactory->create($options)->render();
// Render a custom HTML element which will ask the user to save/update the form due to changing the element.
// This is used for eg. "type" fields and others configured with "onChange"
// (https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Columns/Properties/OnChange.html)
$requestFormEngineUpdate =
(!empty($this->data['processedTca']['ctrl']['type']) && $fieldName === $typeField)
|| (isset($parameterArray['fieldConf']['onChange']) && $parameterArray['fieldConf']['onChange'] === 'reload');
if ($requestFormEngineUpdate) {
$askForUpdate = $backendUser->jsConfirmation(JsConfirmation::TYPE_CHANGE);
$requestMode = $askForUpdate ? 'ask' : 'enforce';
$fieldSelector = sprintf('[name="%s"]', $parameterArray['itemFormElName']);
$resultArray['html'] .= '<typo3-formengine-updater mode="' . htmlspecialchars($requestMode) . '" field="' . htmlspecialchars($fieldSelector) . '"></typo3-formengine-updater>';
if ($resultArray['html'] !== '') {
// Render a custom HTML element which will ask the user to save/update the form due to changing the element.
// This is used for e.g. "type" fields and others configured with "onChange"
// (https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Columns/Properties/OnChange.html)
$requestFormEngineUpdate =
(!empty($this->data['processedTca']['ctrl']['type']) && $fieldName === $typeField)
|| (isset($parameterArray['fieldConf']['onChange']) && $parameterArray['fieldConf']['onChange'] === 'reload');
if ($requestFormEngineUpdate) {
$askForUpdate = $backendUser->jsConfirmation(JsConfirmation::TYPE_CHANGE);
$requestMode = $askForUpdate ? 'ask' : 'enforce';
$fieldSelector = sprintf('[name="%s"]', $parameterArray['itemFormElName']);
$resultArray['html'] .= '<typo3-formengine-updater mode="' . htmlspecialchars($requestMode) . '" field="' . htmlspecialchars($fieldSelector) . '"></typo3-formengine-updater>';
}
}
return $resultArray;
}
......
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