Home » HTML » HTML_QuickForm » Bug #6422
Feature Request: replaceElement addition
Details
| Request #6422 | Feature Request: replaceElement addition |
|---|---|
| Submitted | 2006-01-06 01:09 UTC |
| From | spam-pear at theverge dot com |
| Status | Wont fix |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| 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.