HTML_QuickForm
[ class tree: HTML_QuickForm ] [ index: HTML_QuickForm ] [ all elements ]

Source for file input.php

Documentation is available at input.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0                                                      |
  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. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: input.php,v 1.8 2003/06/18 19:36:20 avb Exp $
  21.  
  22. require_once("HTML/QuickForm/element.php");
  23.  
  24. /**
  25.  * Base class for input form elements
  26.  * 
  27.  * @author       Adam Daniel <adaniel1@eesus.jnj.com>
  28.  * @author       Bertrand Mansion <bmansion@mamasam.com>
  29.  * @version      1.0
  30.  * @since        PHP4.04pl1
  31.  * @access       public
  32.  * @abstract
  33.  */
  34. {
  35.     // {{{ constructor
  36.  
  37.     /**
  38.      * Class constructor
  39.      * 
  40.      * @param    string     Input field name attribute
  41.      * @param    mixed      Label(s) for the input field
  42.      * @param    mixed      Either a typical HTML attribute string or an associative array
  43.      * @since     1.0
  44.      * @access    public
  45.      * @return    void 
  46.      */
  47.     function HTML_QuickForm_input($elementName=null$elementLabel=null$attributes=null)
  48.     {
  49.         $this->HTML_QuickForm_element($elementName$elementLabel$attributes);
  50.     //end constructor
  51.  
  52.     // }}}
  53.     // {{{ setType()
  54.  
  55.     /**
  56.      * Sets the element type
  57.      *
  58.      * @param     string    $type   Element type
  59.      * @since     1.0
  60.      * @access    public
  61.      * @return    void 
  62.      */
  63.     function setType($type)
  64.     {
  65.         $this->_type $type;
  66.         $this->updateAttributes(array('type'=>$type));
  67.     // end func setType
  68.     
  69.     // }}}
  70.     // {{{ setName()
  71.  
  72.     /**
  73.      * Sets the input field name
  74.      * 
  75.      * @param     string    $name   Input field name attribute
  76.      * @since     1.0
  77.      * @access    public
  78.      * @return    void 
  79.      */
  80.     function setName($name)
  81.     {
  82.         $this->updateAttributes(array('name'=>$name));
  83.     //end func setName
  84.     
  85.     // }}}
  86.     // {{{ getName()
  87.  
  88.     /**
  89.      * Returns the element name
  90.      * 
  91.      * @since     1.0
  92.      * @access    public
  93.      * @return    string 
  94.      */
  95.     function getName()
  96.     {
  97.         return $this->getAttribute('name');
  98.     //end func getName
  99.     
  100.     // }}}
  101.     // {{{ setValue()
  102.  
  103.     /**
  104.      * Sets the value of the form element
  105.      *
  106.      * @param     string    $value      Default value of the form element
  107.      * @since     1.0
  108.      * @access    public
  109.      * @return    void 
  110.      */
  111.     function setValue($value)
  112.     {
  113.         $this->updateAttributes(array('value'=>$value));
  114.     // end func setValue
  115.  
  116.     // }}}
  117.     // {{{ getValue()
  118.  
  119.     /**
  120.      * Returns the value of the form element
  121.      *
  122.      * @since     1.0
  123.      * @access    public
  124.      * @return    string 
  125.      */
  126.     function getValue()
  127.     {
  128.         return $this->getAttribute('value');
  129.     // end func getValue
  130.     
  131.     // }}}
  132.     // {{{ toHtml()
  133.  
  134.     /**
  135.      * Returns the input field in HTML
  136.      * 
  137.      * @since     1.0
  138.      * @access    public
  139.      * @return    string 
  140.      */
  141.     function toHtml()
  142.     {
  143.         if ($this->_flagFrozen{
  144.             return $this->getFrozenHtml();
  145.         else {
  146.             return $this->_getTabs('<input' $this->_getAttrString($this->_attributes' />';
  147.         }
  148.     //end func toHtml
  149.  
  150.     // }}}
  151.     // {{{ onQuickFormEvent()
  152.  
  153.     /**
  154.      * Called by HTML_QuickForm whenever form event is made on this element
  155.      *
  156.      * @param     string    $event  Name of event
  157.      * @param     mixed     $arg    event arguments
  158.      * @param     object    $caller calling object
  159.      * @since     1.0
  160.      * @access    public
  161.      * @return    void 
  162.      * @throws
  163.      */
  164.     function onQuickFormEvent($event$arg&$caller)
  165.     {
  166.         // do not use submit values for button-type elements
  167.         $type $this->getType();
  168.         if (('updateValue' != $event||
  169.             ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) {
  170.             parent::onQuickFormEvent($event$arg$caller);
  171.         else {
  172.             $value $this->_findValue($caller->_constantValues);
  173.             if (null === $value{
  174.                 $value $this->_findValue($caller->_defaultValues);
  175.             }
  176.             if (null !== $value{
  177.                 $this->setValue($value);
  178.             }
  179.         }
  180.         return true;
  181.     // end func onQuickFormEvent
  182.  
  183.     // }}}
  184.     // {{{ exportValue()
  185.  
  186.    /**
  187.     * We don't need values from button-type elements (except submit) and files
  188.     */
  189.     function exportValue(&$submitValues$assoc = false)
  190.     {
  191.         $type $this->getType();
  192.         if ('reset' == $type || 'image' == $type || 'button' == $type || 'file' == $type{
  193.             return null;
  194.         else {
  195.             return parent::exportValue($submitValues$assoc);
  196.         }
  197.     }
  198.     
  199.     // }}}
  200. // end class HTML_QuickForm_element
  201. ?>

Documentation generated on Mon, 11 Mar 2019 14:16:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.