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