Last active
August 27, 2019 12:58
-
-
Save mficzel/27bad9f03b8f24b8c204ee80fc130d6e to your computer and use it in GitHub Desktop.
Create custom validation-errors in Neos.Flow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> | |
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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