‪TYPO3CMS  10.4
ValidationResultsViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21 
70 class ‪ValidationResultsViewHelper extends AbstractViewHelper
71 {
72  use CompileWithRenderStatic;
73 
79  protected ‪$escapeOutput = false;
80 
84  public function ‪initializeArguments()
85  {
86  $this->registerArgument('for', '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.', false, '');
87  $this->registerArgument('as', 'string', 'The name of the variable to store the current error', false, 'validationResults');
88  }
89 
96  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
97  {
98  $templateVariableContainer = $renderingContext->getVariableProvider();
99  $controllerContext = $renderingContext->getcontrollerContext();
100  $for = $arguments['for'];
101  $as = $arguments['as'];
102 
103  $validationResults = $controllerContext->getRequest()->getOriginalRequestMappingResults();
104  if ($validationResults !== null && $for !== '') {
105  $validationResults = $validationResults->forProperty($for);
106  }
107  $templateVariableContainer->add($as, $validationResults);
108  ‪$output = $renderChildrenClosure();
109  $templateVariableContainer->remove($as);
110  return ‪$output;
111  }
112 }
‪TYPO3\CMS\Fluid\ViewHelpers\Form
Definition: AbstractFormFieldViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ValidationResultsViewHelper\renderStatic
‪static mixed renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ValidationResultsViewHelper.php:94
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ValidationResultsViewHelper
Definition: ValidationResultsViewHelper.php:71
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ValidationResultsViewHelper\initializeArguments
‪initializeArguments()
Definition: ValidationResultsViewHelper.php:82
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ValidationResultsViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ValidationResultsViewHelper.php:77