[BUGFIX] Submitted form data has precedence over value argument
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / SubmitViewHelper.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 * Creates a submit button.
17 *
18 * = Examples =
19 *
20 * <code title="Defaults">
21 * <f:form.submit value="Send Mail" />
22 * </code>
23 * <output>
24 * <input type="submit" />
25 * </output>
26 *
27 * <code title="Dummy content for template preview">
28 * <f:submit name="mySubmit" value="Send Mail"><button>dummy button</button></f:submit>
29 * </code>
30 * <output>
31 * <input type="submit" name="mySubmit" value="Send Mail" />
32 * </output>
33 *
34 * @api
35 */
36 class SubmitViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
37
38 /**
39 * @var string
40 */
41 protected $tagName = 'input';
42
43 /**
44 * Initialize the arguments.
45 *
46 * @return void
47 * @api
48 */
49 public function initializeArguments() {
50 parent::initializeArguments();
51 $this->registerTagAttribute(
52 'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
53 );
54 $this->registerUniversalTagAttributes();
55 }
56
57 /**
58 * Renders the submit button.
59 *
60 * @return string
61 * @api
62 */
63 public function render() {
64 $name = $this->getName();
65 $this->registerFieldNameForFormTokenGeneration($name);
66
67 $this->tag->addAttribute('type', 'submit');
68 $this->tag->addAttribute('name', $name);
69 $this->tag->addAttribute('value', $this->getValueAttribute());
70
71 return $this->tag->render();
72 }
73 }