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

Support for updating every form element's attributes

Details

Request #6187Support for updating every form element's attributes
Submitted2005-12-07 22:09 UTC
Fromnigel at catalyst dot net dot nz
StatusDuplicate
PackageHTML_QuickForm
PHP Version4.4.0
OSDebian GNU/Linux
Roadmaps(Not assigned)

Comments

[2005-12-07 22:09 UTC] nigel at catalyst dot net dot nz

Description:
------------
I wish to add certain attributes to _every_ form element - in my case an onkeypress attribute but it could be anything. And storing the names of every element is inconvenient.

I suggest adding support for __ALL__, in the same way that you can add filters using __ALL__.

Test script:
---------------
$form =& new HTML_QuickForm();

$form->addElement('text', 'foo');
$form->addElement('text', 'bar');

$form->updateElementAttr('__ALL__', 'size="10"');

// A "patch" is here:
function updateElementAttr($elements, $attrs)
{
if (is_string($elements)) {
if ('__ALL__' == $elements) {
foreach (array_keys($this->_elements) as $key) {
$this->_elements[$key]->updateAttributes($attrs);
}
return;
}
$elements = split('[ ]?,[ ]?', $elements);
}
// continue rest of function

Expected result:
----------------
The attribute(s) should be added to all elements up to the point it was called.