2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997, 1998, 1999, 2000, 2001 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: Adam Daniel <adaniel1@eesus.jnj.com> |
17 // | Bertrand Mansion <bmansion@mamasam.com> |
18 // +----------------------------------------------------------------------+
22 require_once("HTML/QuickForm/element.php");
25 * Base class for input form elements
27 * @author Adam Daniel <adaniel1@eesus.jnj.com>
28 * @author Bertrand Mansion <bmansion@mamasam.com>
34 class HTML_QuickForm_input
extends HTML_QuickForm_element
41 * @param string Input field name attribute
42 * @param mixed Label(s) for the input field
43 * @param mixed Either a typical HTML attribute string or an associative array
48 function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null)
50 $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
57 * Sets the element type
59 * @param string $type Element type
64 function setType($type)
67 $this->updateAttributes(array('type'=>$type));
74 * Sets the input field name
76 * @param string $name Input field name attribute
81 function setName($name)
83 $this->updateAttributes(array('name'=>$name));
90 * Returns the element name
98 return $this->getAttribute('name');
105 * Sets the value of the form element
107 * @param string $value Default value of the form element
112 function setValue($value)
114 $this->updateAttributes(array('value'=>$value));
115 } // end func setValue
121 * Returns the value of the form element
129 return $this->getAttribute('value');
130 } // end func getValue
136 * Returns the input field in HTML
144 if ($this->_flagFrozen
) {
145 return $this->getFrozenHtml();
147 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes
) . ' />';
152 // {{{ onQuickFormEvent()
155 * Called by HTML_QuickForm whenever form event is made on this element
157 * @param string $event Name of event
158 * @param mixed $arg event arguments
159 * @param object $caller calling object
165 function onQuickFormEvent($event, $arg, &$caller)
167 // do not use submit values for button-type elements
168 $type = $this->getType();
169 if (('updateValue' != $event) ||
170 ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) {
171 parent
::onQuickFormEvent($event, $arg, $caller);
173 $value = $this->_findValue($caller->_constantValues
);
174 if (null === $value) {
175 $value = $this->_findValue($caller->_defaultValues
);
177 if (null !== $value) {
178 $this->setValue($value);
182 } // end func onQuickFormEvent
188 * We don't need values from button-type elements (except submit) and files
190 function exportValue(&$submitValues, $assoc = false)
192 $type = $this->getType();
193 if ('reset' == $type ||
'image' == $type ||
'button' == $type ||
'file' == $type) {
196 return parent
::exportValue($submitValues, $assoc);
201 } // end class HTML_QuickForm_element