Skip to content

Commit

Permalink
BUGFIX: Make previous data available to the fusion contexts before su…
Browse files Browse the repository at this point in the history
…bprocesses 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()}
    [email protected] = ${value.isRequired()}
    [email protected][email protected] = ${data.otherValue}
}
```

This even allows to make whole steps conditional

```
process = Neos.Fusion.Form:Runtime.MultiStepProcess {
    steps {
        address {
            ...
        }
        visa {
            @if.fromForeignGalaxy = ${data.galaxy != 'milkyway'}
            ...
        }
    }
}
```
  • Loading branch information
mficzel committed Nov 25, 2021
1 parent 026bdbf commit 36f111a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 36f111a

Please sign in to comment.