[BUGFIX] Submitted form data has precedence over value argument
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / HiddenViewHelper.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 * Renders an <input type="hidden" ...> tag.
16 *
17 * = Examples =
18 *
19 * <code title="Example">
20 * <f:form.hidden name="myHiddenValue" value="42" />
21 * </code>
22 * <output>
23 * <input type="hidden" name="myHiddenValue" value="42" />
24 * </output>
25 *
26 * You can also use the "property" attribute if you have bound an object to the form.
27 * See <f:form> for more documentation.
28 *
29 * @api
30 */
31 class HiddenViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
32
33 /**
34 * @var string
35 */
36 protected $tagName = 'input';
37
38 /**
39 * Initialize the arguments.
40 *
41 * @return void
42 * @api
43 */
44 public function initializeArguments() {
45 parent::initializeArguments();
46 $this->registerUniversalTagAttributes();
47 }
48
49 /**
50 * Renders the hidden field.
51 *
52 * @return string
53 * @api
54 */
55 public function render() {
56 $name = $this->getName();
57 $this->registerFieldNameForFormTokenGeneration($name);
58
59 $this->tag->addAttribute('type', 'hidden');
60 $this->tag->addAttribute('name', $name);
61 $this->tag->addAttribute('value', $this->getValueAttribute());
62
63 return $this->tag->render();
64 }
65
66 }