[CLEANUP] Adjust code to CGL and fix small namespace bugs
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / TextareaViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13 /**
14 * Textarea view helper.
15 * The value of the text area needs to be set via the "value" attribute, as with all other form ViewHelpers.
16 *
17 * = Examples =
18 *
19 * <code title="Example">
20 * <f:form.textarea name="myTextArea" value="This is shown inside the textarea" />
21 * </code>
22 * <output>
23 * <textarea name="myTextArea">This is shown inside the textarea</textarea>
24 * </output>
25 *
26 * @api
27 */
28 class TextareaViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
29
30 /**
31 * @var string
32 */
33 protected $tagName = 'textarea';
34
35 /**
36 * Initialize the arguments.
37 *
38 * @return void
39 * @api
40 */
41 public function initializeArguments() {
42 parent::initializeArguments();
43 $this->registerTagAttribute('rows', 'int', 'The number of rows of a text area');
44 $this->registerTagAttribute('cols', 'int', 'The number of columns of a text area');
45 $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
46 $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
47 $this->registerUniversalTagAttributes();
48 }
49
50 /**
51 * Renders the textarea.
52 *
53 * @return string
54 * @api
55 */
56 public function render() {
57 $name = $this->getName();
58 $this->registerFieldNameForFormTokenGeneration($name);
59 $this->tag->forceClosingTag(TRUE);
60 $this->tag->addAttribute('name', $name);
61 $this->tag->setContent(htmlspecialchars($this->getValue()));
62 $this->setErrorClassAttribute();
63 return $this->tag->render();
64 }
65 }
66
67 ?>