#106177Exception in NodeFactory when having more than one fieldControl of the same name for a field
Description
If a field, e.g. a simple input field has more than one fieldControl with the same name an exception will be raised
TypeError: Cannot access offset of type array on array
in /var/www/html/vendor/typo3/cms-backend/Classes/Form/NodeFactory.php line 166
$className = $this->nodeTypes[$type] ?? $this->nodeTypes[‘unknown’];
How to reproduce:
Have 2 or more nodes registered under the same name for any input field.
For example:
EXT:ai_suite registers a node for pages.seo_title
$GLOBALS['TCA']['pages']['columns']['seo_title']['config'] = array_merge_recursive(
$GLOBALS['TCA']['pages']['columns']['seo_title']['config'],
[
'fieldControl' => [
'importControl' => [
'renderType' => 'aiSeoPageTitle'
]
]
]
);
EXT:sup_header registers another node for the same field
$GLOBALS['TCA']['pages']['columns']['seo_title']['config'] = array_merge_recursive(
$GLOBALS['TCA']['pages']['columns']['seo_title']['config'],
[
'fieldControl' => [
'importControl' => [
'renderType' => 'addIconTextField',
],
],
]
);
Note: both use importControl as the “button” name.
Using different names solves this issue, however there should be a better explanation in the exception message, imo.
From the documentation it is unclear if importControl is a custom value.
I already suggested a change in the documentation.
(https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/FormEngine/Rendering/Index.html#add-fieldcontrol-example)