-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasErrorViewHelper.php
More file actions
46 lines (39 loc) · 1.06 KB
/
Copy pathHasErrorViewHelper.php
File metadata and controls
46 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Fab\Formule\ViewHelpers;
/*
* This file is part of the Fab/Formule project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use Fab\Formule\Service\ValidationService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* View helper which tells whether the field contains possible errors
*/
class HasErrorViewHelper extends AbstractViewHelper
{
/**
* @return void
*/
public function initializeArguments(): void
{
$this->registerArgument('field', 'string', '', true);
}
/**
* @return string
*/
public function render()
{
$field = $this->arguments['field'];
return $this->getValidationService()->hasErrors($field) ? 'has-error' : '';
}
/**
* @return ValidationService|object
*/
protected function getValidationService()
{
return GeneralUtility::makeInstance(ValidationService::class);
}
}