[BUGFIX] TCA: Make ###CURRENT_PID### work in foreign_table_where in IRRE
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormDataProvider / AbstractItemProvider.php
index 302429c..0d81e9b 100644 (file)
@@ -1048,11 +1048,14 @@ abstract class AbstractItemProvider
                 }
                 $foreignTableClause = implode('', $whereClauseParts);
             }
-            // Use pid from parent page clause if in flex flom context
-            if (strpos($foreignTableClause, '###CURRENT_PID###') !== false
-                && !empty($result['flexParentDatabaseRow']['pid'])
-            ) {
-                $effectivePid = $result['flexParentDatabaseRow']['pid'];
+            if (strpos($foreignTableClause, '###CURRENT_PID###') !== false) {
+                // Use pid from parent page clause if in flex form context
+                if (!empty($result['flexParentDatabaseRow']['pid'])) {
+                    $effectivePid = $result['flexParentDatabaseRow']['pid'];
+                // Use pid from database row if in inline context
+                } elseif (!$effectivePid && !empty($result['databaseRow']['pid'])) {
+                    $effectivePid = $result['databaseRow']['pid'];
+                }
             }
 
             $siteRootUid = 0;