[BUGFIX] Flexforms were not considered for FormEngine data preparation 12/44012/5
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 12 Oct 2015 14:22:10 +0000 (16:22 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Mon, 12 Oct 2015 17:43:07 +0000 (19:43 +0200)
With #70504 a selective collection of fields to be processed has been
introduced in FormEngines data providing mechanism. This collection
did not respect fields added by extensions, like the flexform field,
so no flexform was displayed in the end.
Those fields are now added to the process again and flexforms are
displayed as requested.

Change-Id: I49f9137f44588df735d30331465c230f1daee96b
Resolves: #70626
Releases: master
Reviewed-on: http://review.typo3.org/44012
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsProcessCommon.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsProcessCommonTest.php

index da5a8dc..3dfa8cc 100644 (file)
@@ -22,12 +22,14 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class TcaColumnsProcessCommon implements FormDataProviderInterface
 {
+
     /**
      * Determine which common fields are in use and add those to the list of
      * columns that must be processed by the next data providers. Common fields
      * are for example uid, transOrigPointerField or transOrigDiffSourceField.
      *
      * @param array $result
+     *
      * @return array
      */
     public function addData(array $result)
@@ -60,6 +62,18 @@ class TcaColumnsProcessCommon implements FormDataProviderInterface
             $result['columnsToProcess'][] = $tableProperties['transOrigDiffSourceField'];
         }
 
+        // fields added to subtypes_addlist (can be pi_flexform)
+        if (!empty($result['processedTca']['types']['list']['subtypes_addlist'][$result['databaseRow']['list_type']])) {
+            $fields = GeneralUtility::trimExplode(
+                ',',
+                $result['processedTca']['types']['list']['subtypes_addlist'][$result['databaseRow']['list_type']],
+                true
+            );
+            foreach ($fields as $field) {
+                $result['columnsToProcess'][] = $field;
+            }
+        }
+
         return $result;
     }
 }
index 29d8dff..570ad10 100644 (file)
@@ -145,4 +145,56 @@ class TcaColumnsProcessCommonTest extends UnitTestCase
         $expected['columnsToProcess'] = ['l18n_diffsource'];
         $this->assertSame($expected, $this->subject->addData($input));
     }
+
+    /**
+     * @test
+     */
+    public function addDataRegistersSingleSubtypesAddlistFields()
+    {
+        $input = [
+            'columnsToProcess' => [],
+            'processedTca' => [
+                'types' => [
+                    'list' => [
+                        'subtypes_addlist' => [
+                            'aType' => 'aField',
+                        ]
+                    ],
+                ],
+            ],
+            'databaseRow' => [
+                'list_type' => 'aType',
+            ],
+        ];
+
+        $expected = $input;
+        $expected['columnsToProcess'] = ['aField'];
+        $this->assertSame($expected, $this->subject->addData($input));
+    }
+
+    /**
+     * @test
+     */
+    public function addDataRegistersMultipleSubtypesAddlistFields()
+    {
+        $input = [
+            'columnsToProcess' => [],
+            'processedTca' => [
+                'types' => [
+                    'list' => [
+                        'subtypes_addlist' => [
+                            'aType' => 'aField, bField',
+                        ]
+                    ],
+                ],
+            ],
+            'databaseRow' => [
+                'list_type' => 'aType',
+            ],
+        ];
+
+        $expected = $input;
+        $expected['columnsToProcess'] = ['aField', 'bField'];
+        $this->assertSame($expected, $this->subject->addData($input));
+    }
 }