Home » HTML » HTML_QuickForm » Bug #1248
hierselect breaks if element name begins with a number
Details
| Submitted | 2004-04-20 22:46 UTC |
|---|---|
| From | ants dot aasma at mig dot ee |
| Assigned | avb |
| Status | Closed |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | irrelevant |
| 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"
}