From 36f111a42e0b7eb173c739aca3ed578c4de5bd24 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Thu, 25 Nov 2021 13:08:47 +0100 Subject: [PATCH] BUGFIX: Make previous data available to the fusion contexts before subprocesses are evaluated. Currently the `data` is only pushed to the context before the subprocess is rendered. This change ensures that the data ins also in the context before the subprocesses of the multiStepForm are evaluated. That way schemas may use the data for instance to configure fields as required if other fields are set. ``` schema { conditionalField = ${Form.Schema.string()} conditionalField.@process.makeRequired = ${value.isRequired()} conditionalField.@process.makeRequired.@if.hasOtherValue = ${data.otherValue} } ``` This even allows to make whole steps conditional ``` process = Neos.Fusion.Form:Runtime.MultiStepProcess { steps { address { ... } visa { @if.fromForeignGalaxy = ${data.galaxy != 'milkyway'} ... } } } ``` --- .../FusionObjects/MultiStepProcessImplementation.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/Runtime/FusionObjects/MultiStepProcessImplementation.php b/Classes/Runtime/FusionObjects/MultiStepProcessImplementation.php index 2c5296c..97ff690 100644 --- a/Classes/Runtime/FusionObjects/MultiStepProcessImplementation.php +++ b/Classes/Runtime/FusionObjects/MultiStepProcessImplementation.php @@ -77,6 +77,10 @@ public function handle(ActionRequest $request, array $data = []): void $this->state = $this->formStateService->unserializeState($internalArguments['__state']); } + // make the current `data` available to the context before sub processes are evaluated + // as those may have conditions that rely on previous data + $this->runtime->pushContext('data', $this->getData()); + // evaluate the subprocesses this has to be done after the state was restored // as the current data may affect @if conditions $subProcesses = $this->getSubProcesses(); @@ -119,6 +123,9 @@ public function handle(ActionRequest $request, array $data = []): void $request->setArgument('__submittedArgumentValidationResults', new Result()); } } + + // restore fusion context to the state before data was pushed + $this->runtime->popContext(); } /**