Project

General

Profile

Actions

Bug #81855

closed

Add new record wizard fails on Save&Close with "select" field and MM setted

Added by Gianluca Strafella over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Start date:
2017-07-13
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
tca wizard_add
Complexity:
medium
Is Regression:
Sprint Focus:

Description

Hi all,
I've this TCA for a table named as "tx_myext_domain_model_sap":

'ptric' => array(
        'exclude' => 1,
        'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:tx_myext_domain_model_sap.ptric',
        'config' => array(
            'type' => 'select',
            'renderType' => 'selectMultipleSideBySide',
            'foreign_table' => 'tx_usersdbterminali_domain_model_plan',
            'MM' => 'tx_myext_sap_plan_mm',
            'size' => 10,
            'autoSizeMax' => 30,
            'maxitems' => 9999,
            'multiple' => 0,
            'wizards' => array(
                'add' => Array(
                    'module' => array(
                        'name' => 'wizard_add',
                    ),
                    'type' => 'script',
                    'title' => 'Create new',
                    'icon' => 'add.gif',
                    'params' => array(
                        'table' => 'tx_myext_domain_model_plan',
                        'pid' => '###CURRENT_PID###',
                        'setValue' => 'prepend'
                    ),
                ),
            ),
        ),
    ),

With that configuration, we can add a new record in table "tx_myext_domain_model_plan" and relate that in field tx_myext_domain_model_sap.ptric.
When I do this steps:
- add new record
- fill all mandatory fields
- click on "Save and close button"

The field "ptric" in "tx_myext_domain_model_sap" record, loose all old values and contains new "tx_myext_domain_model_plan" record uid, and another arbitrary "tx_myext_domain_model_plan" record id (see screenshoot).

I found the problem in typo3/sysext/backend/Classes/Controller/Wizard/AddController.php, in the function "main".

//[...]
    $result = $formDataCompiler->compile($input);
    $currentParentRow = $result['databaseRow'];
//[...]

in my case, $currentParentRow['ptric'] is equals to value "3"(it's the count of related plan records). The true values are placed in mm table.
That value is forwarded until the typo3/sysext/core/Classes/Database/RelationHandler.php, when the core deletes "all not-used relations":

//[...]

    //Here $removeClauses was built using iteration on $oldMMs array which contains value "3". 
    //This value is wrong, it's the count of related record and not uid list of related records.

    $where = $uidLocal_field . '=' . (int)$uid . $deleteAddWhere . $additionalWhere_tablenames . $additionalWhere;
    $GLOBALS['TYPO3_DB']->exec_DELETEquery($MM_tableName, $where);
//[...]

Thank you,
Gianluca


Files

core-tca-error.png (51.3 KB) core-tca-error.png Gianluca Strafella, 2017-07-13 15:59

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #76863: MM Relation with selectMultipleSideBySide Field - Add wizard resets the MM RelationClosedThomas Hohn2016-06-29

Actions
Related to TYPO3 Core - Bug #82016: Wizards add still not working with MMClosed2017-08-01

Actions
Related to TYPO3 Core - Bug #82461: Backend/TCA: fieldControl->addRecord removes old relations after creating an new entry in the foreign table for the new relation Closed2017-09-12

Actions
Actions

Also available in: Atom PDF