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 #7608

removeRules() function

Details

Request #7608removeRules() function
Submitted2006-05-12 03:56 UTC
Frompaul dot t dot hinze at gmail dot com
StatusWont fix
PackageHTML_QuickForm
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2006-05-12 03:56 UTC] paul dot t dot hinze at gmail dot com

Description:
------------
At this point there is no direct way to remove a rule from an element. The removeElement() function accepts a boolean removeRules which unsets all rules for the deleted element. I propose making this functionality public with a removeRules function that accepts an element name and clears all rules for it. While it would be better to have the ability to delete/edit individual rules, this is an easy way to make functionality that already exists more easily accessible.

Currently, as suggested to me by Justin Patrin, this can be worked around by removing and inserting an element as shown in the test script.

Below that, I've copied code from removeElement to create an admittedly uninformed implementation of this function, but the idea is there.

Test script:
---------------
// current workaround
$form->insertElementBefore($form->removeElement('field',
true), 'elementAfter');

// proposed function
function &removeRules($elementName)
{
if (!isset($this->_elementIndex[$elementName])) {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
return $error;
}
unset($this->_rules[$elementName]);

return;
}

Expected result:
----------------
Function should remove all rules associated with elementName.