TYPO3 CMS  TYPO3_8-7
ButtonViewHelper.php
Go to the documentation of this file.
1 <?php
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 
39 {
43  protected $tagName = 'button';
44 
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  );
91  $this->registerArgument('type', 'string', 'Specifies the type of button (e.g. "button", "reset" or "submit")', false, 'submit');
92  }
93 
100  public function render()
101  {
102  $type = $this->arguments['type'];
103  $name = $this->getName();
105 
106  $this->tag->addAttribute('type', $type);
107  $this->tag->addAttribute('name', $name);
108  $this->tag->addAttribute('value', $this->getValueAttribute());
109  $this->tag->setContent($this->renderChildren());
110 
111  return $this->tag->render();
112  }
113 }
registerTagAttribute($name, $type, $description, $required=false, $default=null)