2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Alexey Borzov <avb@php.net> |
17 // +----------------------------------------------------------------------+
21 require_once 'HTML/QuickForm/element.php';
24 * Class for HTML 4.0 <button> element
26 * @author Alexey Borzov <avb@php.net>
30 class HTML_QuickForm_xbutton
extends HTML_QuickForm_element
33 * Contents of the <button> tag
42 * @param string Button name
43 * @param string Button content (HTML to add between <button></button> tags)
44 * @param mixed Either a typical HTML attribute string or an associative array
47 function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
49 $this->HTML_QuickForm_element($elementName, null, $attributes);
50 $this->setContent($elementContent);
51 $this->setPersistantFreeze(false);
52 $this->_type
= 'xbutton';
58 return '<button' . $this->getAttributes(true) . '>' . $this->_content
. '</button>';
62 function getFrozenHtml()
64 return $this->toHtml();
74 function setName($name)
76 $this->updateAttributes(array(
84 return $this->getAttribute('name');
88 function setValue($value)
90 $this->updateAttributes(array(
98 return $this->getAttribute('value');
103 * Sets the contents of the button element
105 * @param string Button content (HTML to add between <button></button> tags)
107 function setContent($content)
109 $this->_content
= $content;
113 function onQuickFormEvent($event, $arg, &$caller)
115 if ('updateValue' != $event) {
116 return parent
::onQuickFormEvent($event, $arg, $caller);
118 $value = $this->_findValue($caller->_constantValues
);
119 if (null === $value) {
120 $value = $this->_findValue($caller->_defaultValues
);
122 if (null !== $value) {
123 $this->setValue($value);
131 * Returns a 'safe' element's value
133 * The value is only returned if the button's type is "submit" and if this
134 * particlular button was clicked
136 function exportValue(&$submitValues, $assoc = false)
138 if ('submit' == $this->getAttribute('type')) {
139 return $this->_prepareValue($this->_findValue($submitValues), $assoc);