[BUGFIX] Replace ###REC_FIELD with values from DB within FlexForms 62/45962/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 15 Jan 2016 17:13:08 +0000 (18:13 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 15 Jan 2016 18:46:31 +0000 (19:46 +0100)
Replace ###REC_FIELD_ in FlexForm context with values from database.
Within FlexForm context these values need to be found retrieved from
the key flexParentDatabaseRow.

Resolves: #72510
Releases: master, 7.6
Change-Id: I50dd915cf0fcc58e9943c94760033df38ee4f239
Reviewed-on: https://review.typo3.org/45962
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php

index 0b4e083..e682a6e 100644 (file)
@@ -970,7 +970,8 @@ abstract class AbstractItemProvider
                         // "field1###' AND ..." -> array("field1", "' AND ...")
                         $whereClauseSubParts = explode('###', $value, 2);
                         // @todo: Throw exception if there is no value? What happens for NEW records?
-                        $rowFieldValue = $result['databaseRow'][$whereClauseSubParts[0]];
+                        $databaseRowKey = empty($result['flexParentDatabaseRow']) ? 'databaseRow' : 'flexParentDatabaseRow';
+                        $rowFieldValue = isset($result[$databaseRowKey][$whereClauseSubParts[0]]) ? $result[$databaseRowKey][$whereClauseSubParts[0]] : '';
                         if (is_array($rowFieldValue)) {
                             // If a select or group field is used here, it may have been processed already and
                             // is now an array. Use first selected value in this case.
index afc28f3..e17996d 100644 (file)
@@ -1281,6 +1281,22 @@ class TcaSelectItemsTest extends UnitTestCase
                 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',
                 [],
             ],
+            'replace REC_FIELD within FlexForm' => [
+                'AND fTable.title=###REC_FIELD_rowFieldFlexForm###',
+                'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldFlexFormValue\'',
+                [
+                    'databaseRow' => [
+                        'rowFieldThree' => [
+                            0 => 'rowFieldThreeValue'
+                        ]
+                    ],
+                    'flexParentDatabaseRow' => [
+                        'rowFieldFlexForm' => [
+                            0 => 'rowFieldFlexFormValue'
+                        ]
+                    ],
+                ],
+            ],
             'replace REC_FIELD fullQuote' => [
                 'AND fTable.title=###REC_FIELD_rowField###',
                 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',