From 8d0c0bf123c37855bd742bd1ae39e9d3d1c5ae0e Mon Sep 17 00:00:00 2001
From: Susanne Moog <look@susi.dev>
Date: Sat, 7 Mar 2020 16:05:21 +0100
Subject: [PATCH] [BUGFIX] Use parent page ID as PID for suggest fields

TCA select fields have the capabilities for replacing ###CURRENT_PID###
with the parent page ID of the current record. This should always be
<table>.pid. In case of pages the wrong ID was used.

This was now changed to always use the parent page ID indepentent of
the current record. In case there is no parent page row, 0 is given.

Resolves: #90645
Releases: master, 9.5
Change-Id: I8bc04891a009011f4c0d7fd9e59ab306d650b4d2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63603
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 typo3/sysext/backend/Classes/Form/Element/GroupElement.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
index 1392ecf64fb3..69b3c5632532 100644
--- a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
@@ -286,7 +286,7 @@ class GroupElement extends AbstractFormElement
             $html[] =                   ' data-tablename="' . htmlspecialchars($table) . '"';
             $html[] =                   ' data-field="' . htmlspecialchars($elementName) . '"';
             $html[] =                   ' data-uid="' . htmlspecialchars($this->data['databaseRow']['uid']) . '"';
-            $html[] =                   ' data-pid="' . htmlspecialchars($this->data['effectivePid']) . '"';
+            $html[] =                   ' data-pid="' . htmlspecialchars($this->data['parentPageRow']['uid'] ?? 0) . '"';
             $html[] =                   ' data-fieldtype="' . htmlspecialchars($config['type']) . '"';
             $html[] =                   ' data-minchars="' . htmlspecialchars($suggestMinimumCharacters) . '"';
             $html[] =                   ' data-datastructureidentifier="' . htmlspecialchars($dataStructureIdentifier) . '"';
-- 
GitLab