function &addElement($element)
    {
        if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) {
           $elementObject = &$element;
           $elementObject->onQuickFormEvent('updateValue', null, $this);
        } else {
            $args = func_get_args();
            $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1));
            $pear = new PEAR();
            if ($pear->isError($elementObject)) {
                return $elementObject;
            }
        }
        $elementName = $elementObject->getName();

        // Add the element if it is not an incompatible duplicate
        if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
            if ($this->_elements[$this->_elementIndex[$elementName]]->getType() ==
                $elementObject->getType()) {
                $this->_elements[] =& $elementObject;
                $elKeys = array_keys($this->_elements);
                $this->_duplicateIndex[$elementName][] = end($elKeys);
            } else {
                $error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
                return $error;
            }
        } else {
            $this->_elements[] =& $elementObject;
            $elKeys = array_keys($this->_elements);
            $this->_elementIndex[$elementName] = end($elKeys);
        }
        if ($this->_freezeAll) {
            $elementObject->freeze();
        }

        return $elementObject;
    }
function &addElement($element)
    {
        if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) {
           $elementObject = &$element;
           $elementObject->onQuickFormEvent('updateValue', null, $this);
        } else {
            $args = func_get_args();
            $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1));
            $pear = new PEAR();
            if ($pear->isError($elementObject)) {
                return $elementObject;
            }
        }
        $elementName = $elementObject->getName();

        // Add the element if it is not an incompatible duplicate
        if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
            if ($this->_elements[$this->_elementIndex[$elementName]]->getType() ==
                $elementObject->getType()) {
                $this->_elements[] =& $elementObject;
                $elKeys = array_keys($this->_elements);
                $this->_duplicateIndex[$elementName][] = end($elKeys);
            } else {
                $error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
                return $error;
            }
        } else {
            $this->_elements[] =& $elementObject;
            $elKeys = array_keys($this->_elements);
            $this->_elementIndex[$elementName] = end($elKeys);
        }
        if ($this->_freezeAll) {
            $elementObject->freeze();
        }

        return $elementObject;
    }
function & addElement ( $ element ) { if ( is_object ( $ element ) && is_subclass_of ( $ element , 'html_quickform_element' ) ) { $ elementObject = & $ element ; $ elementObject -> onQuickFormEvent ( 'updateValue' , null , $ this ) ; } else { $ args = func_get_args ( ) ; $ elementObject = & $ this -> _loadElement ( 'addElement' , $ element , array_slice ( $ args , 1 ) ) ; $ pear = new PEAR ( ) ; if ( $ pear -> isError ( $ elementObject ) ) { return $ elementObject ; } } $ elementName = $ elementObject -> getName ( ) ; // Add the element if it is not an incompatible duplicate if ( ! empty ( $ elementName ) && isset ( $ this -> _elementIndex [ $ elementName ] ) ) { if ( $ this -> _elements [ $ this -> _elementIndex [ $ elementName ] ] -> getType ( ) == $ elementObject -> getType ( ) ) { $ this -> _elements [ ] = & $ elementObject ; $ elKeys = array_keys ( $ this -> _elements ) ; $ this -> _duplicateIndex [ $ elementName ] [ ] = end ( $ elKeys ) ; } else { $ error = self :: raiseError ( null , QUICKFORM_INVALID_ELEMENT_NAME , null , E_USER_WARNING , "Element '$elementName' already exists in HTML_QuickForm::addElement()" , 'HTML_QuickForm_Error' , true ) ; return $ error ; } } else { $ this -> _elements [ ] = & $ elementObject ; $ elKeys = array_keys ( $ this -> _elements ) ; $ this -> _elementIndex [ $ elementName ] = end ( $ elKeys ) ; } if ( $ this -> _freezeAll ) { $ elementObject -> freeze ( ) ; } return $ elementObject ; }
Adds an element into the form

If $element is a string representing element type, then this
method accepts variable number of parameters, their meaning
and count depending on $element

@param    mixed      $element        element object or type of element to add (text, textarea, file...)
@since    1.0
@return   object     reference to element
@access   public
@throws   HTML_QuickForm_Error
Adds an element into the form