Project

General

Profile

Actions

Bug #99186

open

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

Added by Gaël EVENO about 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2022-11-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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.

No data to display

Actions

Also available in: Atom PDF