[BUGFIX] FormEngine creating section container in new record 15/53215/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 14 Jun 2017 18:55:23 +0000 (20:55 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Sun, 18 Jun 2017 18:11:35 +0000 (20:11 +0200)
If a records has not been persisted and a flex section container
is added, the form compiler needs the "NEW123" uid of parent to
prefix form fields correctly.

Change-Id: Iab3945efa93d2becf636c5cf4f8596bc696cd2e0
Resolves: #80825
Related: #80100
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/53215
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Controller/FormFlexAjaxController.php

index 692dcb8..2ab2343 100644 (file)
@@ -42,6 +42,7 @@ class FormFlexAjaxController extends AbstractFormEngineAjaxController
         $queryParameters = $request->getParsedBody();
 
         $vanillaUid = (int)$queryParameters['vanillaUid'];
+        $databaseRowUid = $queryParameters['databaseRowUid'];
         $command = $queryParameters['command'];
         $tableName = $queryParameters['tableName'];
         $fieldName = $queryParameters['fieldName'];
@@ -76,6 +77,13 @@ class FormFlexAjaxController extends AbstractFormEngineAjaxController
             'processedTca' => $processedTca,
             'flexSectionContainerPreparation' => $flexSectionContainerPreparation,
         ];
+        // A new container on a new record needs the 'NEW123' uid here, see comment
+        // in DatabaseUniqueUidNewRow for more information on that.
+        // @todo: Resolve, maybe with a redifinition of vanillaUid to transport the information more clean through this var?
+        // @see issue #80100 for a series of changes in this area
+        if ($command === 'new') {
+            $formDataCompilerInput['databaseRow']['uid'] = $databaseRowUid;
+        }
         $formData = $formDataCompiler->compile($formDataCompilerInput);
 
         $dataStructure = $formData['processedTca']['columns'][$fieldName]['config']['ds'];