PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #6422

Feature Request: replaceElement addition

Details

Request #6422Feature Request: replaceElement addition
Submitted2006-01-06 01:09 UTC
Fromspam-pear at theverge dot com
StatusWont fix
PackageHTML_QuickForm
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2006-01-06 01:09 UTC] spam-pear at theverge dot com

Description:
------------
Here is some code that handles replace elements.

/**
* Replace an element with the same name
*
* Function uses name in $element passed to find the element to replace
*
* @access public
* @since 3.2.5
* @param object HTML_QuickForm_element Element name is used to find element to replace
* @return object HTML_QuickForm_element reference to replaced element
* @throws HTML_QuickForm_Error
*/
function &replaceElement(&$element)
{
$elementName = $element->getName();
if (!$this->elementExists($elementName)) {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::replaceElement()", 'HTML_QuickForm_Error', true);
return $error;
}
$targetIdx = $this->_elementIndex[$elementName];
$oldElement = $this->_elements[$targetIdx];
$this->_elements[$targetIdx] = $element;
$element->onQuickFormEvent('updateValue', null, $this);
if ($this->_freezeAll) {
$element->freeze();
}
// If not done, the elements will appear in reverse order
ksort($this->_elements);
return $oldElement;
}

// }}}

Expected result:
----------------
Replace the element.