[BUGFIX] Submitted form data has precedence over value argument
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / PasswordViewHelper.php
1 <?php
2
3 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
4
5 /* *
6 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
7 * *
8 * It is free software; you can redistribute it and/or modify it under *
9 * the terms of the GNU Lesser General Public License, either version 3 *
10 * of the License, or (at your option) any later version. *
11 * *
12 * The TYPO3 project - inspiring people to share! *
13 * */
14
15 /**
16 * View Helper which creates a simple Password Text Box (<input type="password">).
17 *
18 * = Examples =
19 *
20 * <code title="Example">
21 * <f:form.password name="myPassword" />
22 * </code>
23 * <output>
24 * <input type="password" name="myPassword" value="default value" />
25 * </output>
26 *
27 * @api
28 */
29 class PasswordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
30
31 /**
32 * @var string
33 */
34 protected $tagName = 'input';
35
36 /**
37 * Initialize the arguments.
38 *
39 * @return void
40 * @api
41 */
42 public function initializeArguments() {
43 parent::initializeArguments();
44 $this->registerTagAttribute(
45 'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
46 );
47 $this->registerTagAttribute(
48 'maxlength', 'int', 'The maxlength attribute of the input field (will not be validated)'
49 );
50 $this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the input field');
51 $this->registerTagAttribute('size', 'int', 'The size of the input field');
52 $this->registerArgument(
53 'errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error'
54 );
55 $this->registerUniversalTagAttributes();
56 }
57
58 /**
59 * Renders the password input field.
60 *
61 * @return string
62 * @api
63 */
64 public function render() {
65 $name = $this->getName();
66 $this->registerFieldNameForFormTokenGeneration($name);
67 $this->setRespectSubmittedDataValue(TRUE);
68
69 $this->tag->addAttribute('type', 'password');
70 $this->tag->addAttribute('name', $name);
71 $this->tag->addAttribute('value', $this->getValueAttribute());
72
73 $this->addAdditionalIdentityPropertiesIfNeeded();
74 $this->setErrorClassAttribute();
75
76 return $this->tag->render();
77 }
78
79 }