2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
   5  * Base class for <input /> form elements
 
   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      Adam Daniel <adaniel1@eesus.jnj.com>
 
  18  * @author      Bertrand Mansion <bmansion@mamasam.com>
 
  19  * @copyright   2001-2011 The PHP Group
 
  20  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
 
  22  * @link        http://pear.php.net/package/HTML_QuickForm
 
  26  * Base class for form elements
 
  28 require_once 'HTML/QuickForm/element.php';
 
  31  * Base class for <input /> form elements
 
  34  * @package     HTML_QuickForm
 
  35  * @author      Adam Daniel <adaniel1@eesus.jnj.com>
 
  36  * @author      Bertrand Mansion <bmansion@mamasam.com>
 
  37  * @version     Release: 3.2.16
 
  41 class HTML_QuickForm_input extends HTML_QuickForm_element
 
  48      * @param    string     Input field name attribute
 
  49      * @param    mixed      Label(s) for the input field
 
  50      * @param    mixed      Either a typical HTML attribute string or an associative array
 
  55     function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null)
 
  57         $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
 
  64      * Sets the element type
 
  66      * @param     string    $type   Element type
 
  71     function setType($type)
 
  74         $this->updateAttributes(array('type'=>$type));
 
  81      * Sets the input field name
 
  83      * @param     string    $name   Input field name attribute
 
  88     function setName($name)
 
  90         $this->updateAttributes(array('name'=>$name));
 
  97      * Returns the element name
 
 105         return $this->getAttribute('name');
 
 112      * Sets the value of the form element
 
 114      * @param     string    $value      Default value of the form element
 
 119     function setValue($value)
 
 121         $this->updateAttributes(array('value'=>$value));
 
 122     } // end func setValue
 
 128      * Returns the value of the form element
 
 136         return $this->getAttribute('value');
 
 137     } // end func getValue
 
 143      * Returns the input field in HTML
 
 151         if ($this->_flagFrozen) {
 
 152             return $this->getFrozenHtml();
 
 154             return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';
 
 159     // {{{ onQuickFormEvent()
 
 162      * Called by HTML_QuickForm whenever form event is made on this element
 
 164      * @param     string    $event  Name of event
 
 165      * @param     mixed     $arg    event arguments
 
 166      * @param     object    &$caller calling object
 
 172     function onQuickFormEvent($event, $arg, &$caller)
 
 174         // do not use submit values for button-type elements
 
 175         $type = $this->getType();
 
 176         if (('updateValue' != $event) ||
 
 177             ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) {
 
 178             parent::onQuickFormEvent($event, $arg, $caller);
 
 180             $value = $this->_findValue($caller->_constantValues);
 
 181             if (null === $value) {
 
 182                 $value = $this->_findValue($caller->_defaultValues);
 
 184             if (null !== $value) {
 
 185                 $this->setValue($value);
 
 189     } // end func onQuickFormEvent
 
 195     * We don't need values from button-type elements (except submit) and files
 
 197     function exportValue(&$submitValues, $assoc = false)
 
 199         $type = $this->getType();
 
 200         if ('reset' == $type || 'image' == $type || 'button' == $type || 'file' == $type) {
 
 203             return parent::exportValue($submitValues, $assoc);
 
 208 } // end class HTML_QuickForm_element