Home » HTML » HTML_QuickForm » Bug #7608
removeRules() function
Details
| Request #7608 | removeRules() function |
|---|---|
| Submitted | 2006-05-12 03:56 UTC |
| From | paul dot t dot hinze at gmail dot com |
| Status | Wont fix |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| 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.