Commit 18411d12 authored by Nicole Cordes's avatar Nicole Cordes Committed by Frank Nägler
Browse files

[BUGFIX] Ensure correct initialization of selectTree value

This patch provides the current set database value in a hidden field as
early as the whole select tree JavaScript is provided. This prevents
data loss if the current record is saved before the select tree was loaded.

Resolves: #86954
Releases: master, 9.5, 8.7
Change-Id: I467b2a52d34b806713cd201a8a2a4f9bb8e92c71
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60415

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
parent 1003a0f1
......@@ -164,7 +164,7 @@ class SelectTreeElement extends AbstractFormElement
$html[] = ' data-tree-show-toolbar="' . $showHeader . '"';
$html[] = ' name="' . htmlspecialchars($parameterArray['itemFormElName']) . '"';
$html[] = ' id="treeinput' . $formElementId . '"';
$html[] = ' value=""';
$html[] = ' value="' . htmlspecialchars(implode(',', $parameterArray['itemFormElValue'])) . '"';
$html[] = '/>';
$html[] = '</div>';
$html[] = '<div id="' . $treeWrapperId . '" class="svg-tree-wrapper" style="height: ' . $heightInPx . 'px;"></div>';
......
......@@ -82,11 +82,12 @@ class TcaSelectTreeItems extends AbstractItemProvider implements FormDataProvide
}
}
if ($result['selectTreeCompileItems']) {
// Prepare the list of currently selected nodes using RelationHandler
$result['databaseRow'][$fieldName] = $this->processDatabaseFieldValue($result['databaseRow'], $fieldName);
$result['databaseRow'][$fieldName] = $this->processSelectFieldValue($result, $fieldName, []);
// Prepare the list of currently selected nodes using RelationHandler
// This is needed to ensure a correct value initialization before the actual tree is loaded
$result['databaseRow'][$fieldName] = $this->processDatabaseFieldValue($result['databaseRow'], $fieldName);
$result['databaseRow'][$fieldName] = $this->processSelectFieldValue($result, $fieldName, []);
if ($result['selectTreeCompileItems']) {
$finalItems = [];
// Prepare the list of "static" items if there are any.
......
Supports Markdown
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