Project

General

Profile

Actions

Bug #89998

closed

Problem in TCA with type select if MM relation is used

Added by Illia Chulkov almost 5 years ago. Updated 5 months ago.

Status:
Closed
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


Files


Related issues 2 (0 open2 closed)

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

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

Actions
Actions #1

Updated by Benni Mack almost 5 years ago

  • Related to Bug #87569: itemsProcFunc in TCA in combination with used table not working correct added
Actions #2

Updated by Philipp Kitzberger over 4 years ago

I can confirm that Illias patch seems to be even working for the case I'm having here:

       'config' => array(
                'type' => 'select',
                'renderType' => 'selectMultipleSideBySide',
                'foreign_table' => 'tx_extension_domain_model_xxx',
                'MM' => 'tx_extension_xxx_yyy_mm',
                'itemsProcFunc' => 'Vendor\Extension\TCE\XXX->getOnlySomeOptions',
       ),

Actions #3

Updated by Georg Ringer over 4 years ago

  • Status changed from New to Accepted
  • Assignee set to Georg Ringer
Actions #4

Updated by Gerrit Code Review over 4 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63758

Actions #5

Updated by Leonie Philine over 4 years ago

I can confirm this fix is working.

On TYPO3 10.3, t3g/blog (latest dev-master) was broken as every time you edited a blog page the author with ID 1 was added.

The MM count "1" (stored in pages[authors]) was added to the items list before loading the related records and appending their UIDs to the items list as well.

The patch being reviewed fixes this misbehavior.

TCA of the affected field:

        'authors' => [
            'exclude' => 1,
            'label' => $ll . 'pages.authors',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectMultipleSideBySide',
                'multiple' => 0,
                'foreign_table' => 'tx_blog_domain_model_author',
                'MM' => 'tx_blog_post_author_mm',
                'minitems' => 0,
                'maxitems' => 99999,
                'behaviour' => [
                    'allowLanguageSynchronization' => true
                ]
            ],
        ],

Actions #6

Updated by Ephraim Härer over 4 years ago

  • Related to Bug #90925: Incorrectly selected items in MM select fields added
Actions #7

Updated by Markus Klein over 4 years ago

@Leonie Philine Bitto please use the "Reply" button in the review system to cast your positive vote on the patch if it works for you. Thanks.

Actions #8

Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63758

Actions #9

Updated by Georg Ringer about 3 years ago

  • Status changed from Under Review to Accepted
Actions #10

Updated by Georg Ringer 5 months ago

I just tested this again in v13 (in styleguide with element select_multiplesidebyside_8 and this is fixed, probably at least in v12, therefore closing the issue.

screenshot shows that the element with ID 2 is not added

Actions #11

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF