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