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