2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5 * Class for HTML 4.0 <button> element
9 * LICENSE: This source file is subject to version 3.01 of the PHP license
10 * that is available through the world-wide-web at the following URI:
11 * http://www.php.net/license/3_01.txt If you did not receive a copy of
12 * the PHP License and are unable to obtain it through the web, please
13 * send a note to license@php.net so we can mail you a copy immediately.
16 * @package HTML_QuickForm
17 * @author Alexey Borzov <avb@php.net>
18 * @copyright 2001-2011 The PHP Group
19 * @license http://www.php.net/license/3_01.txt PHP License 3.01
21 * @link http://pear.php.net/package/HTML_QuickForm
25 * Base class for form elements
27 require_once 'HTML/QuickForm/element.php';
30 * Class for HTML 4.0 <button> element
33 * @package HTML_QuickForm
34 * @author Alexey Borzov <avb@php.net>
35 * @version Release: 3.2.16
38 class HTML_QuickForm_xbutton extends HTML_QuickForm_element
41 * Contents of the <button> tag
50 * @param string Button name
51 * @param string Button content (HTML to add between <button></button> tags)
52 * @param mixed Either a typical HTML attribute string or an associative array
55 function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
57 $this->HTML_QuickForm_element($elementName, null, $attributes);
58 $this->setContent($elementContent);
59 $this->setPersistantFreeze(false);
60 $this->_type = 'xbutton';
66 return '<button' . $this->getAttributes(true) . '>' . $this->_content . '</button>';
70 function getFrozenHtml()
72 return $this->toHtml();
82 function setName($name)
84 $this->updateAttributes(array(
92 return $this->getAttribute('name');
96 function setValue($value)
98 $this->updateAttributes(array(
106 return $this->getAttribute('value');
111 * Sets the contents of the button element
113 * @param string Button content (HTML to add between <button></button> tags)
115 function setContent($content)
117 $this->_content = $content;
121 function onQuickFormEvent($event, $arg, &$caller)
123 if ('updateValue' != $event) {
124 return parent::onQuickFormEvent($event, $arg, $caller);
126 $value = $this->_findValue($caller->_constantValues);
127 if (null === $value) {
128 $value = $this->_findValue($caller->_defaultValues);
130 if (null !== $value) {
131 $this->setValue($value);
139 * Returns a 'safe' element's value
141 * The value is only returned if the button's type is "submit" and if this
142 * particlular button was clicked
144 function exportValue(&$submitValues, $assoc = false)
146 if ('submit' == $this->getAttribute('type')) {
147 return $this->_prepareValue($this->_findValue($submitValues), $assoc);