Issue Bug Closed

#99186FormEditor issue if 'type' property in YAML has to be defined as array (ex: for mapping a field called type)

Gaël EVENO 11/24/22, 21:21 updated 10/09/26, 18:05

Description

Hello,

I use the saveToDatabase finisher in a form where I need to map a field called ‘type’.

...
finishers:
  -
    identifier: SaveToDatabaseIfMember
    options:
      -
        table: tx_news_domain_model_news
...
...
        databaseColumnMappings:
          pid:
            value: 24
          type:
            value: MyVendor\MyExtension\Domain\Model\MyEvent

The form works fine in frontend but if I open it in backend:

(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception

PHP Warning: array_key_exists(): The first argument should be either a string or an integer in /var/www/MyTypo3/typo3/public/typo3/sysext/form/Classes/Controller/FormEditorController.php line 580

The problem is that in transformFormDefinitionForFormEditor() there are 2 calls to transformMultiValuePropertiesForFormEditor() to parse/transform ‘type’ and ‘identifier’ properties.

Unfortunately, in my case, ‘type’ is also a field in tx_news_domain_model_news and has to be defined as an array:

        databaseColumnMappings:
 ...
          type:
            value: MyVendor\MyExtension\Domain\Model\MyEvent
 ...

So modifying form/Classes/Controller/FormEditorController.php line 580 :


if (array_key_exists($identifier, $multiValueProperties)) {
$multiValuePropertiesForIdentifier = $multiValueProperties[$identifier];

to

if ((!is_array($identifier)) && array_key_exists($identifier, $multiValueProperties)) {
$multiValuePropertiesForIdentifier = $multiValueProperties[$identifier];

solves the problem. No side effect for the moment with the FormEditor.

Reviews 1

History 1

  1. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-10-09T18:05:23+00:00" > 10/09/26, 18:05 </span>

    This has been fixed in the meantime by #102340 (“[BUGFIX] Fix PHP error in FormEditor property preparation”, https://review.typo3.org/c/Packages/TYPO3.CMS/+/81702), which landed in November 2023 for main and 12.4.

    FormEditorController::transformMultiValuePropertiesForFormEditor() now only does the lookup when the value is a string:

    if (is_string($identifier) && array_key_exists($identifier, $multiValueProperties)) {

    That’s the same guard proposed in this report, so a finisher option like databaseColumnMappings.type or elements.type with an array value no longer breaks the form editor. The fix is in 12.4, 13.4, 14.3 and main.