‪TYPO3CMS  ‪main
ButtonViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
48 {
52  protected ‪$tagName = 'button';
53 
54  public function ‪initializeArguments(): void
55  {
56  parent::initializeArguments();
57  $this->registerTagAttribute(
58  'autofocus',
59  'string',
60  'Specifies that a button should automatically get focus when the page loads'
61  );
62  $this->registerTagAttribute(
63  'disabled',
64  'string',
65  'Specifies that the input element should be disabled when the page loads'
66  );
67  $this->registerTagAttribute('form', 'string', 'Specifies one or more forms the button belongs to');
68  $this->registerTagAttribute(
69  'formaction',
70  'string',
71  'Specifies where to send the form-data when a form is submitted. Only for type="submit"'
72  );
73  $this->registerTagAttribute(
74  'formenctype',
75  'string',
76  '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")'
77  );
78  $this->registerTagAttribute(
79  'formmethod',
80  'string',
81  'Specifies how to send the form-data (which HTTP method to use). Only for type="submit" (e.g. "get" or "post")'
82  );
83  $this->registerTagAttribute(
84  'formnovalidate',
85  'string',
86  'Specifies that the form-data should not be validated on submission. Only for type="submit"'
87  );
88  $this->registerTagAttribute(
89  'formtarget',
90  'string',
91  'Specifies where to display the response after submitting the form. Only for type="submit" (e.g. "_blank", "_self", "_parent", "_top", "framename")'
92  );
93  $this->registerUniversalTagAttributes();
94  $this->registerArgument('type', 'string', 'Specifies the type of button (e.g. "button", "reset" or "submit")', false, 'submit');
95  }
96 
97  public function ‪render(): string
98  {
99  $type = $this->arguments['type'];
100  $name = $this->‪getName();
102 
103  $this->tag->addAttribute('type', $type);
104  $this->tag->addAttribute('name', $name);
105  $this->tag->addAttribute('value', $this->‪getValueAttribute());
106  $this->tag->setContent($this->renderChildren());
107  $this->tag->forceClosingTag(true);
108 
109  return $this->tag->render();
110  }
111 }
‪TYPO3\CMS\Fluid\ViewHelpers\Form
Definition: AbstractFormFieldViewHelper.php:18
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper\registerFieldNameForFormTokenGeneration
‪registerFieldNameForFormTokenGeneration(string $fieldName)
Definition: AbstractFormViewHelper.php:100
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ButtonViewHelper\$tagName
‪string $tagName
Definition: ButtonViewHelper.php:51
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ButtonViewHelper\initializeArguments
‪initializeArguments()
Definition: ButtonViewHelper.php:53
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ButtonViewHelper\render
‪render()
Definition: ButtonViewHelper.php:96
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\getName
‪getName()
Definition: AbstractFormFieldViewHelper.php:79
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ButtonViewHelper
Definition: ButtonViewHelper.php:48
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
Definition: AbstractFormFieldViewHelper.php:37
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\getValueAttribute
‪mixed getValueAttribute()
Definition: AbstractFormFieldViewHelper.php:147