Deprecation: #97857 - Deprecate __inheritances operator in form configuration
See forge#97857
Description
The custom
__ operator, which was available only in
YAML configuration files of EXT:form, has been deprecated.
Previously, this operator was used within form definition files to inherit and reuse configuration parts between form element definitions. With native YAML functionality now providing equivalent and more flexible features, this TYPO3-specific operator is no longer necessary.
Developers are encouraged to migrate to standard YAML features such as anchors, aliases, and overrides to avoid code duplication and to simplify form configuration maintenance.
Impact
Using the
__ operator inside a custom YAML form configuration
in EXT:form will trigger a PHP
E_ error.
Affected installations
All installations with custom form definitions or form element configurations
that use the
__ operator in their EXT:form YAML files
are affected and need to update those files accordingly.
Migration
The custom TYPO3 implementation using
__ can be replaced
with standard YAML syntax.
Developers can achieve the same result by using anchors (
&),
aliases (
*), and overrides (
<<:).
Before:
mixins:
formElementMixins:
BaseFormElementMixin:
1761226183:
identifier: custom
templateName: Inspector-TextEditor
label: Custom editor
propertyPath: custom
OtherBaseFormElementMixin:
1761226184:
identifier: otherCustom
templateName: Inspector-TextEditor
label: Other custom editor
propertyPath: otherCustom
prototypes:
standard:
formElementsDefinition:
Text:
formEditor:
editors:
__inheritances:
10: 'mixins.formElementMixins.BaseFormElementMixin'
20: 'mixins.formElementMixins.OtherBaseFormElementMixin'
After:
customEditor: &customEditor
1761226183:
identifier: custom
templateName: Inspector-TextEditor
label: Custom editor
propertyPath: custom
otherCustomEditor: &otherCustomEditor
identifier: otherCustom
templateName: Inspector-TextEditor
label: Other custom editor
propertyPath: otherCustom
prototypes:
standard:
formElementsDefinition:
Text:
formEditor:
editors:
<<: *customEditor
1761226184: *otherCustomEditor
Inheriting a complete element across files
A common use case of
__ was to base a new form element on
the complete configuration of an existing (core) element and then override only
a few properties. YAML anchors and aliases are file-local and therefore cannot
reference a definition from another file. This can instead be solved with the
imports key and
%...% placeholders of the TYPO3 YAML loader.
Because a placeholder is resolved after parsing and replaces a whole value, the inheritance and the overrides must live in two files: the imported file copies the complete element subtree, the importing file then merges its overrides on top.
Imported file, copies the whole
Text element to
Custom:
imports:
- { resource: 'EXT:form/Configuration/Form/Base/FormElements/Text.yaml' }
prototypes:
standard:
formElementsDefinition:
CustomText: '%prototypes.standard.formElementsDefinition.Text%'
Importing file, overrides only single properties:
imports:
- { resource: 'EXT:my_extension/Configuration/Form/CustomElement/CustomTextInherit.yaml' }
prototypes:
standard:
formElementsDefinition:
CustomText:
formEditor:
label: 'Custom Text'
group: custom
Custom now inherits the complete configuration of the core
Text element (
implementation,
rendering,
all
form,
predefined, …) while only the
listed properties are overridden.