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

Hierselect generates notices when using strings as array keys

Details

Submitted2004-04-11 10:10 UTC
Fromaashley at optimiser dot com
Assignedmansion
StatusClosed
PackageHTML_QuickForm
PHP Version5CVS-2004-04-11 (dev)
OSLinux
Roadmaps(Not assigned)

Comments

[2004-04-11 10:10 UTC] aashley at optimiser dot com

Description:
------------
When using string based keys in the hierselect data passed in Notices are generated about undefined constants and defaulting to string (occurs when running with errors = ERROR_ALL).

Below patch fixes the problem:

--- hierselect.php.orig 2004-04-11 18:06:47.753606572 +0800
+++ hierselect.php 2004-04-11 18:12:57.619135744 +0800
@@ -227,6 +227,7 @@
$select->loadArray($array);

$value = is_array($v = $select->getValue()) ? $v[0] : key($array);
+ $value = is_string($value) ? "'$value'" : $value;
$toLoad .= '['.$value.']';
}
}

[2004-04-11 11:22 UTC] bmansion at mamasam dot com

Can you please send me an example to reproduce the bug so that I can check whether there are other problems too. Thanks,

Bertrand

[2004-04-12 01:23 UTC] aashley at optimiser dot com

Examples a bit big to post here so its available at:

http://frood.cernun.net/hierselect.php
http://frood.cernun.net/hierselect.phps

[2004-04-12 08:39 UTC] bmansion at mamasam dot com

This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pear.php.net.

In case this was a pear.php.net website problem, the change will show
up on the website in short time.

Thank you for the report, and for helping us make PEAR better.

BTW, your example is wrong as you use 2 times the same element name.