[BUGFIX] displayCond in Flexform sheets 71/42071/3
authorAndreas Wolf <andreas.wolf@typo3.org>
Tue, 28 Jul 2015 19:54:46 +0000 (21:54 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 29 Jul 2015 11:19:34 +0000 (13:19 +0200)
This actually fixes two independent bugs:

1) The condition matcher could not access information from another
sheet, because only the current sheet’s data was handed over. That is
simply wrong, as no information depending on a sheet name should be used
in the condition (otherwise you could hide the sheet you’re seeing and
never be able to get it back).

2) The field name in the split condition was changed, but the changed
condition was not passed to the condition matcher.

Resolves: #67879
Releases: master
Change-Id: Iecc194dddc749d70cbe13b52fa4aff62c63ace3c
Reviewed-on: http://review.typo3.org/42071
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Form/Container/AbstractContainer.php
typo3/sysext/backend/Classes/Form/Container/FlexFormNoTabsContainer.php
typo3/sysext/backend/Classes/Form/Container/FlexFormTabsContainer.php

index 5e8edd3..4415126 100644 (file)
@@ -262,9 +262,10 @@ abstract class AbstractContainer extends AbstractNode {
         *
         * @param string $displayCondition The condition to evaluate
         * @param array $flexFormData Given data the condition is based on
+        * @param string $flexFormLanguage Flex form language key
         * @return bool TRUE if condition matched
         */
-       protected function evaluateFlexFormDisplayCondition($displayCondition, $flexFormData) {
+       protected function evaluateFlexFormDisplayCondition($displayCondition, $flexFormData, $flexFormLanguage) {
                $elementConditionMatcher = GeneralUtility::makeInstance(ElementConditionMatcher::class);
 
                $splitCondition = GeneralUtility::trimExplode(':', $displayCondition);
@@ -272,11 +273,10 @@ abstract class AbstractContainer extends AbstractNode {
                $fakeRow = array();
                switch ($splitCondition[0]) {
                        case 'FIELD':
-                               // @todo: Not 100% sure if that is correct this way
                                list($_sheetName, $fieldName) = GeneralUtility::trimExplode('.', $splitCondition[1]);
-                               $fieldValue = $flexFormData[$fieldName];
+                               $fieldValue = $flexFormData[$_sheetName][$flexFormLanguage][$fieldName];
                                $splitCondition[1] = $fieldName;
-                               $dataStructure['ROOT']['TCEforms']['displayCond'] = join(':', $splitCondition);
+                               $displayCondition = join(':', $splitCondition);
                                $fakeRow = array($fieldName => $fieldValue);
                                break;
                        case 'HIDE_FOR_NON_ADMINS':
index abec299..da5b419 100644 (file)
@@ -52,7 +52,8 @@ class FlexFormNoTabsContainer extends AbstractContainer {
                        $displayConditionDefinition = $flexFormDataStructureArray['ROOT']['TCEforms']['displayCond'];
                        $displayConditionResult = $this->evaluateFlexFormDisplayCondition(
                                $displayConditionDefinition,
-                               $flexFormRowDataSubPart
+                               $flexFormRowDataSubPart,
+                               $flexFormCurrentLanguage
                        );
                }
                if (!$displayConditionResult) {
index 5cede74..73ccfbc 100644 (file)
@@ -59,7 +59,8 @@ class FlexFormTabsContainer extends AbstractContainer {
                                $displayConditionDefinition = $sheetDataStructure['ROOT']['TCEforms']['displayCond'];
                                $displayConditionResult = $this->evaluateFlexFormDisplayCondition(
                                        $displayConditionDefinition,
-                                       $flexFormRowSheetDataSubPart
+                                       $flexFormRowData['data'],
+                                       $flexFormCurrentLanguage
                                );
                        }
                        if (!$displayConditionResult) {