[BUGFIX] Submitted form data has precedence over value argument
[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 /**
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 TextareaViewHelper extends \TYPO3\CMS\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('autofocus', 'string', 'Specifies that a text area should automatically get focus when the page loads');
45 $this->registerTagAttribute('rows', 'int', 'The number of rows of a text area');
46 $this->registerTagAttribute('cols', 'int', 'The number of columns of a text area');
47 $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
48 $this->registerTagAttribute('placeholder', 'string', 'The placeholder of the textarea');
49 $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
50 $this->registerUniversalTagAttributes();
51 }
52
53 /**
54 * Renders the textarea.
55 *
56 * @return string
57 * @api
58 */
59 public function render() {
60 $name = $this->getName();
61 $this->registerFieldNameForFormTokenGeneration($name);
62 $this->setRespectSubmittedDataValue(TRUE);
63
64 $this->tag->forceClosingTag(TRUE);
65 $this->tag->addAttribute('name', $name);
66 $this->tag->setContent(htmlspecialchars($this->getValueAttribute()));
67
68 $this->addAdditionalIdentityPropertiesIfNeeded();
69 $this->setErrorClassAttribute();
70
71 return $this->tag->render();
72 }
73
74 }