‪TYPO3CMS  ‪main
TextareaViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
37 {
41  protected ‪$tagName = 'textarea';
42 
43  public function ‪initializeArguments(): void
44  {
45  parent::initializeArguments();
46  $this->registerTagAttribute('autofocus', 'string', 'Specifies that a text area should automatically get focus when the page loads');
47  $this->registerTagAttribute('rows', 'int', 'The number of rows of a text area');
48  $this->registerTagAttribute('cols', 'int', 'The number of columns of a text area');
49  $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
50  $this->registerTagAttribute('placeholder', 'string', 'The placeholder of the textarea');
51  $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
52  $this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the textarea', false);
53  $this->registerArgument('required', 'bool', 'Specifies whether the textarea is required', false, false);
54  $this->registerUniversalTagAttributes();
55  }
56 
57  public function ‪render(): string
58  {
59  $required = $this->arguments['required'];
60  $name = $this->‪getName();
63 
64  $this->tag->forceClosingTag(true);
65  $this->tag->addAttribute('name', $name);
66  if ($required === true) {
67  $this->tag->addAttribute('required', 'required');
68  }
69  $this->tag->setContent(htmlspecialchars((string)$this->‪getValueAttribute()));
72 
73  return $this->tag->render();
74  }
75 }
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\setErrorClassAttribute
‪setErrorClassAttribute()
Definition: AbstractFormFieldViewHelper.php:331
‪TYPO3\CMS\Fluid\ViewHelpers\Form\TextareaViewHelper\$tagName
‪string $tagName
Definition: TextareaViewHelper.php:40
‪TYPO3\CMS\Fluid\ViewHelpers\Form
Definition: AbstractFormFieldViewHelper.php:18
‪TYPO3\CMS\Fluid\ViewHelpers\Form\TextareaViewHelper\initializeArguments
‪initializeArguments()
Definition: TextareaViewHelper.php:42
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper\registerFieldNameForFormTokenGeneration
‪registerFieldNameForFormTokenGeneration(string $fieldName)
Definition: AbstractFormViewHelper.php:100
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\setRespectSubmittedDataValue
‪setRespectSubmittedDataValue(bool $respectSubmittedDataValue)
Definition: AbstractFormFieldViewHelper.php:69
‪TYPO3\CMS\Fluid\ViewHelpers\Form\TextareaViewHelper
Definition: TextareaViewHelper.php:37
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\getName
‪getName()
Definition: AbstractFormFieldViewHelper.php:79
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
Definition: AbstractFormFieldViewHelper.php:37
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\addAdditionalIdentityPropertiesIfNeeded
‪addAdditionalIdentityPropertiesIfNeeded()
Definition: AbstractFormFieldViewHelper.php:241
‪TYPO3\CMS\Fluid\ViewHelpers\Form\TextareaViewHelper\render
‪render()
Definition: TextareaViewHelper.php:56
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\getValueAttribute
‪mixed getValueAttribute()
Definition: AbstractFormFieldViewHelper.php:147