From da67cfa2680ad8cf8a74a9e93824fef294d77366 Mon Sep 17 00:00:00 2001 From: bwaidelich Date: Tue, 13 Sep 2022 14:26:03 +0200 Subject: [PATCH] BUGFIX: Update form state upon element submission Fixes a regression that was introduced with #149 that led to `onSubmit()` callbacks to only get hold of the form state of previous pages. With this fix `$formRuntime->getFormState()->getFormValues()` in a custom element will return the previously handled form values, even of the current form page. Fixes: #156 --- Classes/Core/Runtime/FormRuntime.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Classes/Core/Runtime/FormRuntime.php b/Classes/Core/Runtime/FormRuntime.php index e6b0798..3a7dd29 100644 --- a/Classes/Core/Runtime/FormRuntime.php +++ b/Classes/Core/Runtime/FormRuntime.php @@ -277,11 +277,9 @@ protected function mapAndValidatePage(Page $page) $element->onSubmit($this, $value); $pageFormValues[$element->getIdentifier()] = $value; + $this->formState->setFormValue($element->getIdentifier(), $value); } $page->onSubmit($this, $pageFormValues); - foreach ($pageFormValues as $elementIdentifier => $value) { - $this->formState->setFormValue($elementIdentifier, $value); - } // The more parts the path has, the more early it is processed usort($propertyPathsForWhichPropertyMappingShouldHappen, function ($a, $b) {