[BUGFIX] Suggest wizard in FlexForms for new records 23/47223/2
authorNicole Cordes <typo3@cordes.co>
Sat, 12 Mar 2016 11:47:04 +0000 (12:47 +0100)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Sun, 13 Mar 2016 19:06:55 +0000 (20:06 +0100)
Within new records the suggest wizard doesn't work in FlexForm fields.
Due to unexpected incoming data the field configuration can't be fetched.
This patch ensures sanitized data before fetching FlexForms field
configuration.

Resolves: #73864
Releases: master, 7.6
Change-Id: I7e9a72c2aa6d1efed943845aa2198ce153b75fb8
Reviewed-on: https://review.typo3.org/47223
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/backend/Classes/Form/Wizard/SuggestWizard.php

index 75f205b..dcd1330 100644 (file)
@@ -284,21 +284,25 @@ class SuggestWizard
 
             $flexfieldTCAConfig = $GLOBALS['TCA'][$table]['columns'][$parts[0]]['config'];
             // @todo: should be done via data preparation, resolveAllSheetsInDS() can be deprecated then
+            if (substr($row['uid'], 0, 3) === 'NEW') {
+                // We have to cleanup record information as they are coming from FormEngines DataProvider
+                $pointerFields = GeneralUtility::trimExplode(',', $flexfieldTCAConfig['ds_pointerField']);
+                foreach ($pointerFields as $pointerField) {
+                    if (is_array($row[$pointerField])) {
+                        $row[$pointerField] = $row[$pointerField][0];
+                    }
+                }
+            }
             $flexformDSArray = BackendUtility::getFlexFormDS($flexfieldTCAConfig, $row, $table, $parts[0]);
             $flexformDSArray = GeneralUtility::resolveAllSheetsInDS($flexformDSArray);
             $flexformElement = $parts[count($parts) - 2];
-            $continue = true;
             foreach ($flexformDSArray as $sheet) {
                 foreach ($sheet as $_ => $dataStructure) {
                     $fieldConfig = $this->getNestedDsFieldConfig($dataStructure, $flexformElement);
                     if (!empty($fieldConfig)) {
-                        $continue = false;
-                        break;
+                        break(2);
                     }
                 }
-                if (!$continue) {
-                    break;
-                }
             }
             // Flexform field name levels are separated with | instead of encapsulation in [];
             // reverse this here to be compatible with regular field names.