7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* Abstract class for extension
26
require_once 'Zend/View/Helper/FormElement.php';
30
* Helper to generate a "button" element
35
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
36
* @license http://framework.zend.com/license/new-bsd New BSD License
38
class Zend_View_Helper_FormButton extends Zend_View_Helper_FormElement
41
* Generates a 'button' element.
45
* @param string|array $name If a string, the element name. If an
46
* array, all other parameters are ignored, and the array elements
47
* are extracted in place of added parameters.
49
* @param mixed $value The element value.
51
* @param array $attribs Attributes for the element tag.
53
* @return string The element XHTML.
55
public function formButton($name, $value = null, $attribs = null)
57
$info = $this->_getInfo($name, $value, $attribs);
58
extract($info); // name, id, value, attribs, options, listsep, disable
62
if (isset($attribs['content'])) {
63
$content = $attribs['content'];
64
unset($attribs['content']);
69
// Ensure type is sane
71
if (isset($attribs['type'])) {
72
$attribs['type'] = strtolower($attribs['type']);
73
if (in_array($attribs['type'], array('submit', 'reset', 'button'))) {
74
$type = $attribs['type'];
76
unset($attribs['type']);
81
$attribs['disabled'] = 'disabled';
84
$content = ($escape) ? $this->view->escape($content) : $content;
87
. ' name="' . $this->view->escape($name) . '"'
88
. ' id="' . $this->view->escape($id) . '"'
89
. ' type="' . $type . '"';
91
// add a value if one is given
93
$xhtml .= ' value="' . $this->view->escape($value) . '"';
96
// add attributes and close start tag
97
$xhtml .= $this->_htmlAttribs($attribs) . '>';
99
// add content and end tag
100
$xhtml .= $content . '</button>';