Skip to content

BUGFIX: validated step will not be validated again #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Classes/Runtime/Domain/FormState.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ public function getPart(string $partName): ?array
return $this->parts[$partName] ?? null;
}

/**
* @param string $partName
* @return void
*/
public function removePart(string $partName): void
{
unset($this->parts[$partName]);
}

/**
* @return string[]
*/
Expand Down
23 changes: 18 additions & 5 deletions Classes/Runtime/FusionObjects/MultiStepProcessImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class MultiStepProcessImplementation extends AbstractFusionObject implements Pro
*/
protected $targetSubProcessKey;

/**
* @var string
*/
protected $prevSubProcessKey;

/**
* Return reference to self during fusion evaluation
* @return $this
Expand Down Expand Up @@ -91,6 +96,13 @@ public function handle(ActionRequest $request, array $data = []): void
$this->currentSubProcessKey = (string)reset($subProcessKeys);
}

// select previous subprocess key
if (array_key_exists('__prev', $internalArguments)
&& $internalArguments['__prev']
) {
$this->prevSubProcessKey = (string)$internalArguments['__prev'];
}

// store target subprocess, but only if it already was submitted
if (array_key_exists('__target', $internalArguments)
&& $internalArguments['__target']
Expand All @@ -113,11 +125,12 @@ public function handle(ActionRequest $request, array $data = []): void
$this->currentSubProcessKey,
$currentSubProcess->getData()
);
} else {
if ($this->targetSubProcessKey) {
$request->setArgument('__submittedArguments', []);
$request->setArgument('__submittedArgumentValidationResults', new Result());
}
} elseif (
$this->state
&& $this->targetSubProcessKey !== $this->prevSubProcessKey
) {
$this->state->removePart($this->currentSubProcessKey);
$this->targetSubProcessKey = (string)$internalArguments['__current'];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ prototype(Neos.Fusion.Form:Runtime.MultiStepProcess) {
hiddenFields = afx`
<Neos.Fusion.Form:Hidden field.name="__state" attributes.value={process.state} @if.has={process.state} />
<Neos.Fusion.Form:Hidden field.name="__current" attributes.value={process.current} @if.has={process.current} />
<Neos.Fusion.Form:Hidden field.name="__prev" attributes.value={process.prev} @if.has={process.prev} />
`

prototype(Neos.Fusion.Form:Runtime.SingleStepProcess) {
Expand Down