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

hierselect breaks if element name begins with a number

Details

Submitted2004-04-20 22:46 UTC
Fromants dot aasma at mig dot ee
Assignedavb
StatusClosed
PackageHTML_QuickForm
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2004-04-20 22:46 UTC] ants dot aasma at mig dot ee

Description:
------------
If the hierselect elementname begins with a number the generated javascript.

Suggested fix:
in HTML/QuickForm/hierselect.php function _setJS
replace
$this->_jsArrayName = $this->getName();
with
$this->_jsArrayName = 'someString_'.$this->getName();

Reproduce code:
---------------
require_once 'HTML/QuickForm.php';
$form =& new HTML_QuickForm('frmTest', 'get');
$select =& $form->addElement('hierselect', '0Name', 'Name begins with a number');
$select->setMainOptions($mainOptions = array('foo'));
$select->setSecOptions($secOptions = array(array('bar')));
$form->display();

Expected result:
----------------
<script type="text/javascript">
someString_0Name_0 = {
"0":"bar"
}

Actual result:
--------------
<script type="text/javascript">
0Name_0 = {
"0":"bar"
}