diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 90b3346c6429850f5175d0dfe5187644d89569a8..5c8657cd194a369dd7410648d19d108616917aad 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -2910,7 +2910,7 @@ class DataHandler implements LoggerAwareInterface foreach ($DSelements as $key => $dsConf) { // Array/Section: if (isset($DSelements[$key]['type']) && $DSelements[$key]['type'] === 'array') { - if (!is_array($dataValues[$key]['el'])) { + if (!is_array($dataValues[$key]['el'] ?? null)) { continue; } diff --git a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php index 18d6fb5ababe3b3004d1eff823ee540d67c647bc..ac446a9888a6e0b730a555a4136d233b3e6129a8 100644 --- a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php +++ b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php @@ -652,6 +652,188 @@ class DataHandlerTest extends UnitTestCase $this->subject->_call('checkValueForFlex', [], [], [], '', 0, '', '', 0, 0, 0, ''); } + public function checkValue_flex_procInData_travDSDataProvider(): iterable + { + yield 'Flat structure with TCEForms' => [ + 'dataValues' => [ + 'field1' => [ + 'vDEF' => 'wrong input', + ], + ], + 'DSelements' => [ + 'field1' => [ + 'TCEforms' => [ + 'label' => 'A field', + 'config' => [ + 'type' => 'input', + 'eval' => 'required,int', + ], + ], + ], + ], + 'expected' => [ + 'field1' => [ + 'vDEF' => 0, + ], + ], + ]; + + yield 'Flat structure without TCEForms' => [ + 'dataValues' => [ + 'field1' => [ + 'vDEF' => 'wrong input', + ], + ], + 'DSelements' => [ + 'field1' => [ + 'label' => 'A field', + 'config' => [ + 'type' => 'input', + 'eval' => 'required,int', + ], + ], + ], + 'expected' => [ + 'field1' => [ + 'vDEF' => 0, + ], + ], + ]; + + yield 'Array structure with TCEforms key' => [ + 'dataValues' => [ + 'section' => [ + 'el' => [ + '1' => [ + 'container1' => [ + 'el' => [ + 'field1' => [ + 'vDEF' => 'wrong input', + ], + ], + ], + ], + ], + ], + ], + 'DSelements' => [ + 'section' => [ + 'type' => 'array', + 'section' => true, + 'el' => [ + 'container1' => [ + 'type' => 'array', + 'el' => [ + 'field1' => [ + 'TCEforms' => [ + 'label' => 'A field', + 'config' => [ + 'type' => 'input', + 'eval' => 'required,int', + ], + ], + ], + ], + ], + ], + ], + ], + 'expected' => [ + 'section' => [ + 'el' => [ + '1' => [ + 'container1' => [ + 'el' => [ + 'field1' => [ + 'vDEF' => 0, + ], + ], + ], + ], + ], + ], + ], + ]; + + yield 'Array structure without TCEforms key' => [ + 'dataValues' => [ + 'section' => [ + 'el' => [ + '1' => [ + 'container_1' => [ + 'el' => [ + 'field1' => [ + 'vDEF' => 'wrong input', + ], + ], + ], + ], + ], + ], + ], + 'DSelements' => [ + 'section' => [ + 'type' => 'array', + 'section' => true, + 'el' => [ + 'container_1' => [ + 'type' => 'array', + 'el' => [ + 'field1' => [ + 'label' => 'A field', + 'config' => [ + 'type' => 'input', + 'eval' => 'required,int', + ], + ], + ], + ], + ], + ], + ], + 'expected' => [ + 'section' => [ + 'el' => [ + '1' => [ + 'container_1' => [ + 'el' => [ + 'field1' => [ + 'vDEF' => 0, + ], + ], + ], + ], + ], + ], + ], + ]; + } + + /** + * This test ensures, that the eval method checkValue_SW is called on + * flexform structures. + * + * @test + * @dataProvider checkValue_flex_procInData_travDSDataProvider + */ + public function checkValue_flex_procInData_travDS(array $dataValues, array $DSelements, array $expected): void + { + $pParams = [ + 'tt_content', + 777, + '<?xml ... ?>', + 'update', + 1, + 'tt_content:777:pi_flexform', + 0, + ]; + + $languageServiceProphecy = $this->prophesize(LanguageService::class); + $GLOBALS['LANG'] = $languageServiceProphecy->reveal(); + $this->subject->checkValue_flex_procInData_travDS($dataValues, [], $DSelements, $pParams, '', ''); + self::assertSame($expected, $dataValues); + } + ///////////////////////////////////// // Tests concerning log ///////////////////////////////////// diff --git a/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php b/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php index 1ac281f2edd0b236e0b38bee44aa29f8606ded48..1ab63eecd768d78eaa429e3983391643e381bbb9 100644 --- a/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php +++ b/typo3/sysext/form/Classes/Domain/Configuration/FlexformConfiguration/Processors/FinisherOptionGenerator.php @@ -88,7 +88,11 @@ class FinisherOptionGenerator extends AbstractProcessor } $sheetElements = $this->converterDto->getResult(); - $sheetElements['settings.finishers.' . $finisherIdentifier . '.' . $optionKey]['TCEforms'] = $elementConfiguration; + if ($elementConfiguration['section'] ?? false) { + $sheetElements['settings.finishers.' . $finisherIdentifier . '.' . $optionKey] = $elementConfiguration; + } else { + $sheetElements['settings.finishers.' . $finisherIdentifier . '.' . $optionKey]['TCEforms'] = $elementConfiguration; + } $this->converterDto->setResult($sheetElements); }