PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #3988

javascript component doesnt work for array field names

Details

Submitted2005-03-29 06:12 UTC
Fromluk822 at 8chter dot com
Assignedavb
StatusClosed
PackageHTML_QuickForm
PHP Version4.3.9
OSWin XP
Roadmaps(Not assigned)

Comments

[2005-03-29 06:12 UTC] luk822 at 8chter dot com

Description:
------------
Problem with PEAR :: QuickForm :: Hierselect Element

latest version

when giving the form element an array type field name the javascript funtionality breaks

Reproduce code:
---------------
$element =& HTML_QuickForm::createElement(
'hierselect',
'record[somefield]',
'Some Field'
);

note: naming the field above "record[somefield]" above( in order to retrieve data as array ) will cause a javascript error and doesn't allow the script to work

Expected result:
----------------
the javascript should work for array field names also

Actual result:
--------------
javascript doesn't work

[2005-07-05 20:09 UTC] brmcfee at gmail dot com

Note: this bug is OS-independent.

To make the bug report a little more clear, what happens is that elements with array names such as "record[somefield]" get munged into the form "hs_record[somefield]_otherfield" by hierselect.

I've come up with a quick hack to make it work. All you have to do is change the _setJS() function in hierselect.php as follows:

-$this->_jsArrayName = 'hs_' . $this->getName();
+$this->_jsArrayName = 'hs_' . preg_replace('/\[|\]/', '_', $this->getName());