[BUGFIX] Inline in flex 82/43482/6
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 22 Sep 2015 16:29:59 +0000 (18:29 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 25 Sep 2015 14:37:56 +0000 (16:37 +0200)
Inline elements within flex forms do not differ from "normal" inline
relations on DB side. For inline relation handling it looks like a
direct table to table connection, even if the connect data is
stored within xml.

The resolve logic triggered by the inline process data provider
thus needs table name and uid of the "parent" record to resolve
inline elements correctly.

Change-Id: I06a97221cadb9ac772494f8e8d9045c41a50d305
Resolves: #69867
Releases: master
Reviewed-on: http://review.typo3.org/43482
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Sebastian Michaelsen <michaelsen@t3seo.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexProcess.php

index bc53304..c4874e1 100644 (file)
@@ -347,6 +347,7 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
        protected function modifyDataStructureAndDataValuesByFlexFormSegmentGroup(array $result, $fieldName, $pageTsConfig) {
                $dataStructure = $result['processedTca']['columns'][$fieldName]['config']['ds'];
                $dataValues = $result['databaseRow'][$fieldName];
+               $tableName = $result['tableName'];
 
                $availableLanguageCodes = $result['processedTca']['columns'][$fieldName]['config']['ds']['meta']['availableLanguageCodes'];
                if ($dataStructure['meta']['langChildren']) {
@@ -376,9 +377,9 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
                        $dataStructureSheetElements = $dataStructureSheetDefinition['ROOT']['el'];
 
                        // Prepare pageTsConfig of this sheet
-                       $pageTsConfigMerged['TCEFORM.']['flexDummyTable.'] = [];
+                       $pageTsConfigMerged['TCEFORM.'][$tableName . '.'] = [];
                        if (isset($pageTsConfig[$dataStructureSheetName . '.']) && is_array($pageTsConfig[$dataStructureSheetName . '.'])) {
-                               $pageTsConfigMerged['TCEFORM.']['flexDummyTable.'] = $pageTsConfig[$dataStructureSheetName . '.'];
+                               $pageTsConfigMerged['TCEFORM.'][$tableName . '.'] = $pageTsConfig[$dataStructureSheetName . '.'];
                        }
 
                        foreach ($languagesOnSheetLevel as $isoSheetLevel) {
@@ -415,14 +416,16 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
                                                                                        }
                                                                                        foreach ($languagesOnElementLevel as $isoElementLevel) {
                                                                                                $langElementLevel = 'v' . $isoElementLevel;
-                                                                                               $valueArray = [];
+                                                                                               $valueArray = [
+                                                                                                       'uid' => $result['databaseRow']['uid'],
+                                                                                               ];
                                                                                                $command = 'new';
                                                                                                if (array_key_exists($langElementLevel, $singleFieldValueArray)) {
                                                                                                        $command = 'edit';
                                                                                                        $valueArray[$singleFieldName] = $singleFieldValueArray[$langElementLevel];
                                                                                                }
                                                                                                $inputToFlexFormSegment = [
-                                                                                                       'tableName' => 'flexDummyTable',
+                                                                                                       'tableName' => $result['tableName'],
                                                                                                        'command' => $command,
                                                                                                        // It is currently not possible to have pageTsConfig for section container
                                                                                                        'pageTsConfigMerged' => [],
@@ -475,10 +478,12 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
                                                                                foreach ($languagesOnElementLevel as $isoElementLevel) {
                                                                                        $langElementLevel = 'v' . $isoElementLevel;
                                                                                        $inputToFlexFormSegment = [
-                                                                                               'tableName' => 'flexDummyTable',
+                                                                                               'tableName' => $result['tableName'],
                                                                                                'command' => 'new',
                                                                                                'pageTsConfigMerged' => [],
-                                                                                               'databaseRow' => [],
+                                                                                               'databaseRow' => [
+                                                                                                       'uid' => $result['databaseRow']['uid'],
+                                                                                               ],
                                                                                                'vanillaTableTca' => [
                                                                                                        'ctrl' => [],
                                                                                                        'columns' => [
@@ -520,7 +525,10 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
                                        } else {
                                                foreach ($languagesOnElementLevel as $isoElementLevel) {
                                                        $langElementLevel = 'v' . $isoElementLevel;
-                                                       $valueArray = [];
+                                                       $valueArray = [
+                                                               // uid of "parent" is given down for inline elements to resolve correctly
+                                                               'uid' => $result['databaseRow']['uid'],
+                                                       ];
                                                        $command = 'new';
                                                        if (isset($dataValues['data'][$dataStructureSheetName][$langSheetLevel][$dataStructureSheetElementName])
                                                                && array_key_exists($langElementLevel, $dataValues['data'][$dataStructureSheetName][$langSheetLevel][$dataStructureSheetElementName])
@@ -529,7 +537,8 @@ class TcaFlexProcess extends AbstractItemProvider implements FormDataProviderInt
                                                                $valueArray[$dataStructureSheetElementName] = $dataValues['data'][$dataStructureSheetName][$langSheetLevel][$dataStructureSheetElementName][$langElementLevel];
                                                        }
                                                        $inputToFlexFormSegment = [
-                                                               'tableName' => 'flexDummyTable',
+                                                               // tablename of "parent" is given down for inline elements to resolve correctly
+                                                               'tableName' => $result['tableName'],
                                                                'command' => $command,
                                                                'pageTsConfigMerged' => $pageTsConfigMerged,
                                                                'databaseRow' => $valueArray,