Skip to content
Snippets Groups Projects
Commit 7e2928e5 authored by Chris Müller's avatar Chris Müller Committed by Benni Mack
Browse files

[BUGFIX] Set parent uid in newly created IRRE child record

When creating a new IRRE child element the uid of the parent element
was not set. This is a problem when you use an itemsProcFunc for a
select column which relies on the parent's element uid to show
according values. With the parent uid you can query the stored values.

Resolves: #63777
Releases: master, 9.5
Change-Id: I898de29020bf68e25de9ef1d80cc20353a635524
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61480


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarTobi Kretschmann <tobi@tobishome.de>
Reviewed-by: default avatarHenning Liebe <h.liebe@neusta.de>
Reviewed-by: default avatarSascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: default avatarFelix P. <f.pachowsky@neusta.de>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent c9eecb93
Branches
Tags
No related merge requests found
......@@ -49,6 +49,7 @@ class DatabaseRowInitializeNew implements FormDataProviderInterface
$result = $this->setDefaultsFromDefaultValues($result);
$result = $this->setDefaultsFromInlineRelations($result);
$result = $this->setDefaultsFromInlineParentLanguage($result);
$result = $this->setDefaultsFromInlineParentUid($result);
$result = $this->setPid($result);
return $result;
......@@ -223,6 +224,24 @@ class DatabaseRowInitializeNew implements FormDataProviderInterface
return $result;
}
/**
* Set the parent uid of inline relations created via ajax to the corresponding foreign field
*
* @param array $result Result array
* @return array
*/
protected function setDefaultsFromInlineParentUid(array $result): array
{
$isInlineChild = $result['isInlineChild'] ?? false;
$parentField = $result['inlineParentConfig']['foreign_field'] ?? false;
if ($isInlineChild && $parentField && !empty($result['inlineParentUid'])) {
$result['databaseRow'][$parentField] = $result['inlineParentUid'];
}
return $result;
}
/**
* Set the pid. This is either the vanillaUid (see description in FormDataCompiler),
* or a pid given by pageTsConfig for inline children.
......
......@@ -709,4 +709,28 @@ class DatabaseRowInitializeNewTest extends UnitTestCase
$expected['databaseRow']['pid'] = 42;
self::assertSame($expected, (new DatabaseRowInitializeNew)->addData($input));
}
/**
* @test
*/
public function addDataSetsUidOfParentFieldIfRecordIsInlineChild()
{
$input = [
'command' => 'new',
'tableName' => 'aTable',
'vanillaUid' => 23,
'neighborRow' => null,
'inlineChildChildUid' => null,
'databaseRow' => [],
'isInlineChild' => true,
'inlineParentUid' => 42,
'inlineParentConfig' => [
'foreign_field' => 'theParentField'
],
];
$expected = $input;
$expected['databaseRow']['theParentField'] = 42;
$expected['databaseRow']['pid'] = 23;
self::assertSame($expected, (new DatabaseRowInitializeNew)->addData($input));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment