[BUGFIX] Fix alias of SaltedPasswordsService
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / ButtonViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Creates a button.
19 *
20 * Examples
21 * --------
22 *
23 * Defaults::
24 *
25 * <f:form.button>Send Mail</f:form.button>
26 *
27 * Output::
28 *
29 * <button type="submit" name="" value="">Send Mail</button>
30 *
31 * Disabled cancel button with some HTML5 attributes::
32 *
33 * <f:form.button type="reset" name="buttonName" value="buttonValue" disabled="disabled" formmethod="post" formnovalidate="formnovalidate">Cancel</f:form.button>
34 *
35 * Output::
36 *
37 * <button disabled="disabled" formmethod="post" formnovalidate="formnovalidate" type="reset" name="myForm[buttonName]" value="buttonValue">Cancel</button>
38 */
39 class ButtonViewHelper extends AbstractFormFieldViewHelper
40 {
41 /**
42 * @var string
43 */
44 protected $tagName = 'button';
45
46 /**
47 * Initialize the arguments.
48 *
49 * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
50 */
51 public function initializeArguments()
52 {
53 parent::initializeArguments();
54 $this->registerTagAttribute(
55 'autofocus',
56 'string',
57 'Specifies that a button should automatically get focus when the page loads'
58 );
59 $this->registerTagAttribute(
60 'disabled',
61 'string',
62 'Specifies that the input element should be disabled when the page loads'
63 );
64 $this->registerTagAttribute('form', 'string', 'Specifies one or more forms the button belongs to');
65 $this->registerTagAttribute(
66 'formaction',
67 'string',
68 'Specifies where to send the form-data when a form is submitted. Only for type="submit"'
69 );
70 $this->registerTagAttribute(
71 'formenctype',
72 'string',
73 'Specifies how form-data should be encoded before sending it to a server. Only for type="submit" (e.g. "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain")'
74 );
75 $this->registerTagAttribute(
76 'formmethod',
77 'string',
78 'Specifies how to send the form-data (which HTTP method to use). Only for type="submit" (e.g. "get" or "post")'
79 );
80 $this->registerTagAttribute(
81 'formnovalidate',
82 'string',
83 'Specifies that the form-data should not be validated on submission. Only for type="submit"'
84 );
85 $this->registerTagAttribute(
86 'formtarget',
87 'string',
88 'Specifies where to display the response after submitting the form. Only for type="submit" (e.g. "_blank", "_self", "_parent", "_top", "framename")'
89 );
90 $this->registerUniversalTagAttributes();
91 $this->registerArgument('type', 'string', 'Specifies the type of button (e.g. "button", "reset" or "submit")', false, 'submit');
92 }
93
94 /**
95 * Renders the button.
96 *
97 * @return string
98 */
99 public function render()
100 {
101 $type = $this->arguments['type'];
102 $name = $this->getName();
103 $this->registerFieldNameForFormTokenGeneration($name);
104
105 $this->tag->addAttribute('type', $type);
106 $this->tag->addAttribute('name', $name);
107 $this->tag->addAttribute('value', $this->getValueAttribute());
108 $this->tag->setContent($this->renderChildren());
109
110 return $this->tag->render();
111 }
112 }