Bug #81855
closedAdd new record wizard fails on Save&Close with "select" field and MM setted
0%
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
Updated by Georg Ringer over 7 years ago
- Status changed from New to Needs Feedback
please check out #76863 as it has been solved recently
Updated by Georg Ringer over 7 years ago
- Related to Bug #76863: MM Relation with selectMultipleSideBySide Field - Add wizard resets the MM Relation added
Updated by Gianluca Strafella over 7 years ago
Hi,
sure the problem is the same but patch in https://forge.typo3.org/issues/76863#note-27 does not work in my version (TYPO3 7.6.20).
This is the problem:
// Check the row for its datatype. If it is an array it stores the relation
// to other rows. Implode it into a comma separated list to be able to restore the stored
// values after the wizard falls back to the parent record
$currentValue = $currentParentRow[$this->P['field']];
if (is_array($currentValue)) {
$currentValue = implode(',', array_column($currentValue, 'uid'));
}
This is the dump of variable "$currentParentRow[$this->P['field']]" in my case:
array(2 items) 0 => "51" (2 chars) 1 => "46" (2 chars)
and so, implode statement fails.
Gianluca
Updated by Anke Altintop over 7 years ago
I can confirm that is not solved in Typo3 8.7.* either. The problem remains the same even with the integrated patch
Updated by Riccardo De Contardi over 7 years ago
- Status changed from Needs Feedback to New
Updated by Anke Altintop about 7 years ago
Solution https://forge.typo3.org/issues/82016 worked
Updated by Riccardo De Contardi about 7 years ago
- Related to Bug #82016: Wizards add still not working with MM added
Updated by Riccardo De Contardi about 7 years ago
- Related to Bug #82461: Backend/TCA: fieldControl->addRecord removes old relations after creating an new entry in the foreign table for the new relation added
Updated by Riccardo De Contardi over 6 years ago
- Status changed from New to Closed
@Kevin no-lastname-given Ditscheid thank you for your feedback - closed.
If you think that this is the wrong decision or experience the issue again, please reopen it or open a new issue with a reference to this one.