Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active August 27, 2019 12:58
Show Gist options
  • Save mficzel/27bad9f03b8f24b8c204ee80fc130d6e to your computer and use it in GitHub Desktop.
Save mficzel/27bad9f03b8f24b8c204ee80fc130d6e to your computer and use it in GitHub Desktop.
Create custom validation-errors in Neos.Flow
// render all validation errors of current request
renderer = afx`
<div @if.hasErrors={request.internalArguments.__submittedArgumentValidationResults.flattenedErrors}>
ERORR
<ul>
<Neos.Fusion:Loop items={request.internalArguments.__submittedArgumentValidationResults.flattenedErrors} itemKey="path" itemName="errors">
<Neos.Fusion:Loop items={errors} itemName="error">
<li>{path} - {error}</li>
</Neos.Fusion:Loop>
</Neos.Fusion:Loop>
</ul>
</div>
`
public function testAction()
{
// create result
$result = new Result();
$result->addError( new Error("a generic error") );
$result->forProperty('foo.bar')->addError(new Error( "a path error") );
// fake ValidationResult for the request we are forwarding to
$arguments = [];
$arguments['__submittedArguments'] = [];
$arguments['__submittedArgumentValidationResults'] = $result;
// forward to "other" action but with the defined errors
$this->forward('action', 'Example', 'Vendor.Site', $arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment