Task #6560 ยป ResetViewHelper.php

Soren Malling, 2010-02-22 14:42

 
1
<?php
2

    
3
/*                                                                        *
4
 * This script belongs to the FLOW3 package "Fluid".                      *
5
 *                                                                        *
6
 * It is free software; you can redistribute it and/or modify it under    *
7
 * the terms of the GNU Lesser General Public License as published by the *
8
 * Free Software Foundation, either version 3 of the License, or (at your *
9
 * option) any later version.                                             *
10
 *                                                                        *
11
 * This script is distributed in the hope that it will be useful, but     *
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
13
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
14
 * General Public License for more details.                               *
15
 *                                                                        *
16
 * You should have received a copy of the GNU Lesser General Public       *
17
 * License along with the script.                                         *
18
 * If not, see http://www.gnu.org/licenses/lgpl.html                      *
19
 *                                                                        *
20
 * The TYPO3 project - inspiring people to share!                         *
21
 *                                                                        */
22

    
23
/**
24
 * Creates a submit button.
25
 *
26
 * = Examples =
27
 *
28
 * <code title="Defaults">
29
 * <f:form.reset value="Reset Fields" />
30
 * </code>
31
 *
32
 * Output:
33
 * <input type="reset" />
34
 *
35
 * <code title="Dummy content for template preview">
36
 * <f:submit name="mySubmit" value="Reset Fields"><button>dummy button</button></f:submit>
37
 * </code>
38
 *
39
  * Output:
40
 * <input type="reset" name="mySubmit" value="Reset Fields" />
41
 *
42
 * @version $Id: ResetViewHelper.php 1734 2009-11-25 21:53:57Z stucki $
43
 * @package Fluid
44
 * @subpackage ViewHelpers\Form
45
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
46
 * @api
47
 * @scope prototype
48
 */
49
class Tx_Fluid_ViewHelpers_Form_ResetViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
50

    
51
	/**
52
	 * @var string
53
	 */
54
	protected $tagName = 'input';
55

    
56
	/**
57
	 * Initialize the arguments.
58
	 *
59
	 * @return void
60
	 * @author Soren Malling <sma@dkm.dk>
61
	 * @api
62
	 */
63
	public function initializeArguments() {
64
		parent::initializeArguments();
65
		$this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
66
		$this->registerUniversalTagAttributes();
67
	}
68

    
69
	/**
70
	 * Renders the reset button.
71
	 *
72
	 * @return string
73
	 * @author Soren Malling <sma@dkm.dk>
74
	 * @api
75
	 */
76
	public function render() {
77
		$name = $this->getName();
78
		$this->registerFieldNameForFormTokenGeneration($name);
79

    
80
		$this->tag->addAttribute('type', 'reset');
81
		$this->tag->addAttribute('name', $name);
82
		$this->tag->addAttribute('value', $this->getValue());
83

    
84
		return $this->tag->render();
85
	}
86
}
87

    
88
?>
    (1-1/1)