[BUGFIX] FormEngine: Remove hardcoded fieldnames for subtypes_addlist 52/44452/4
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 31 Oct 2015 17:41:13 +0000 (18:41 +0100)
committerMathias Schreiber <mathias.schreiber@wmdb.de>
Sat, 31 Oct 2015 18:24:23 +0000 (19:24 +0100)
Take into account the configured fieldnames for recordType and subType
selection instead of using the hardcoded values list and list_type.

Resolves: #71212
Related: #62508
Releases: master
Change-Id: I81cad273859489464b2d902092ff81c0bd17ae10
Reviewed-on: https://review.typo3.org/44452
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsProcessCommon.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsProcessCommonTest.php
typo3/sysext/frontend/Configuration/TCA/tt_content.php

index 3dfa8cc..2572109 100644 (file)
@@ -63,14 +63,18 @@ class TcaColumnsProcessCommon implements FormDataProviderInterface
         }
 
         // 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;
+        $recordTypeValue = $result['recordTypeValue'];
+        if (!empty($result['processedTca']['types'][$recordTypeValue]['subtype_value_field'])) {
+            $subtypeFieldName = $result['processedTca']['types'][$recordTypeValue]['subtype_value_field'];
+            if (!empty($result['processedTca']['types'][$recordTypeValue]['subtypes_addlist'][$result['databaseRow'][$subtypeFieldName]])) {
+                $fields = GeneralUtility::trimExplode(
+                    ',',
+                    $result['processedTca']['types'][$recordTypeValue]['subtypes_addlist'][$result['databaseRow'][$subtypeFieldName]],
+                    true
+                );
+                foreach ($fields as $field) {
+                    $result['columnsToProcess'][] = $field;
+                }
             }
         }
 
index 570ad10..ab38f7e 100644 (file)
@@ -152,10 +152,12 @@ class TcaColumnsProcessCommonTest extends UnitTestCase
     public function addDataRegistersSingleSubtypesAddlistFields()
     {
         $input = [
+            'recordTypeValue' => 'list',
             'columnsToProcess' => [],
             'processedTca' => [
                 'types' => [
                     'list' => [
+                        'subtype_value_field' => 'list_type',
                         'subtypes_addlist' => [
                             'aType' => 'aField',
                         ]
@@ -178,18 +180,20 @@ class TcaColumnsProcessCommonTest extends UnitTestCase
     public function addDataRegistersMultipleSubtypesAddlistFields()
     {
         $input = [
+            'recordTypeValue' => 'aType',
             'columnsToProcess' => [],
             'processedTca' => [
                 'types' => [
-                    'list' => [
+                    'aType' => [
+                        'subtype_value_field' => 'theSubtypeValueField',
                         'subtypes_addlist' => [
-                            'aType' => 'aField, bField',
+                            'theSubtypeValue' => 'aField, bField',
                         ]
                     ],
                 ],
             ],
             'databaseRow' => [
-                'list_type' => 'aType',
+                'theSubtypeValueField' => 'theSubtypeValue',
             ],
         ];
 
index 3b7d2e4..0313895 100644 (file)
@@ -1212,8 +1212,8 @@ return array(
                 'categorized_content' => 'pages',
             ),
             'subtypes_addlist' => array(
-                'categorized_pages' => 'selected_categories;;menu, category_field;;menu',
-                'categorized_content' => 'selected_categories;;menu, category_field;;menu',
+                'categorized_pages' => 'selected_categories, category_field',
+                'categorized_content' => 'selected_categories, category_field',
             )
         ),
         'shortcut' => array(