Project

General

Profile

Actions

Bug #89998

open

Problem in TCA with type select if MM relation is used

Added by Illia Chulkov over 4 years ago. Updated over 2 years ago.

Status:
Accepted
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2019-12-20
Due date:
% Done:

0%

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

Description

Hi all
I have a problem in TCA if i used type select and MM relation
A similar problem has been described in #87569
Except that i have not used itemsProcFunc

'test' => [
            'exclude' => false,
            'label' => 'Test',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectMultipleSideBySide',
                'allowed' => 'tx_ext_domain_model_body',
                'MM' => 'tx_ext_service_body_mm',
                'foreign_table' => 'tx_ext_domain_model_body',
                'foreign_table_where' => 'ORDER BY title ASC',
                'size' => 5,
                'minitems' => 0
            ]
        ],

When i select two records, after saving i have three records
For example:
I select two records with uid 5 and 6, after saving i get three records with uid 2, 5, 6
Because records uid take from the MM table as well as from the test field

I found a solution to this problem
In file typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php line 1226

$currentDatabaseValueArray = array_key_exists($fieldName, $result['databaseRow']) ? $result['databaseRow'][$fieldName] : [];

I added a condition that checks if the MM field contains a relation

$currentDatabaseValueArray = (array_key_exists($fieldName, $result['databaseRow']) && empty($fieldConfig['config']['MM'])) ? $result['databaseRow'][$fieldName] : [];

Please check if my decision is correct


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Bug #87569: itemsProcFunc in TCA in combination with used table not working correctNew2019-01-29

Actions
Related to TYPO3 Core - Bug #90925: Incorrectly selected items in MM select fieldsClosed2020-04-01

Actions
Actions

Also available in: Atom PDF