[BUGFIX] Show correct number of inline records defined in flexform 85/32985/4
authorDaniel Alder <dalder@snowflake.ch>
Fri, 26 Sep 2014 07:42:36 +0000 (09:42 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 15 Oct 2014 17:36:22 +0000 (19:36 +0200)
getRelatedRecordsArray() is expecting comma separated list of record ids
Before this patch the full flexform xml was passed.
Now we detect whether a field is a flexform and try to extract the
correct field values from it.

Resolves: #56882
Releases: master, 6.2
Change-Id: I50db5dfd5f07bbc20e369c0a07f2f294afb85321
Reviewed-on: http://review.typo3.org/32985
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Classes/Form/Element/InlineElement.php

index 1a8c143..4fd3b46 100644 (file)
@@ -1486,7 +1486,22 @@ class InlineElement {
                                } elseif ($localizationMode == 'select') {
                                        $transOrigRec = $this->getRecord(0, $transOrigTable, $transOrigPointer);
                                        $pid = $transOrigRec['pid'];
-                                       $recordsOriginal = $this->getRelatedRecordsArray($pid, $foreignTable, $transOrigRec[$field]);
+                                       $fieldValue = $transOrigRec[$field];
+
+                                       // Checks if it is a flexform field
+                                       if ($GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'flex') {
+                                               $flexFormParts = $this->extractFlexFormParts($PA['itemFormElName']);
+                                               $flexData = GeneralUtility::xml2array($fieldValue);
+                                               /** @var  $flexFormTools  \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools */
+                                               $flexFormTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
+                                               $flexFormFieldValue = $flexFormTools->getArrayValueByPath($flexFormParts, $flexData);
+
+                                               if ($flexFormFieldValue !== NULL) {
+                                                       $fieldValue = $flexFormFieldValue;
+                                               }
+                                       }
+
+                                       $recordsOriginal = $this->getRelatedRecordsArray($pid, $foreignTable, $fieldValue);
                                }
                        }
                }
@@ -2614,5 +2629,4 @@ class InlineElement {
 
                return $flexFormParts;
        }
-
 }