Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Form.validationResults ViewHelper <f:form.validationResults>
Validation results ViewHelper
Examples
Output error messages as a list:
<f:form.validationResults>
<f:if condition="{validationResults.flattenedErrors}">
<ul class="errors">
<f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
<li>{propertyPath}
<ul>
<f:for each="{errors}" as="error">
<li>{error.code}: {error}</li>
</f:for>
</ul>
</li>
</f:for>
</ul>
</f:if>
</f:form.validationResults>
Output:
<ul class="errors">
<li>1234567890: Validation errors for argument "newBlog"</li>
</ul>
Output error messages for a single property:
<f:form.validationResults for="someProperty">
<f:if condition="{validationResults.flattenedErrors}">
<ul class="errors">
<f:for each="{validationResults.errors}" as="error">
<li>{error.code}: {error}</li>
</f:for>
</ul>
</f:if>
</f:form.validationResults>
Output:
<ul class="errors">
<li>1234567890: Some error message</li>
</ul>
Source code
Go to the source code of this ViewHelper: ValidationResultsViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
for
-
- Type
- string
The name of the error name (e.g. argument name or property name). This can also be a property path (like blog.title), and will then only display the validation errors of that property.
as
-
- Type
- string
- Default
'validation
Results'
The name of the variable to store the current error