Quickform ->select -> setSelected
| From: | Emiliano Saurin | Date: | Wed, 03 Jul 2002 11:30:39 +0000 |
| Subject: | Quickform ->select -> setSelected | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-1798@lists.php.net to get a copy of this message | ||
Hello,
when i have a string with a comma as an option of the select, the class
can't set the default selection of a select .
The function setSelected of the HTML_QuickForm_selec makes:
[originalcode]
...
if (is_string($values)) {
$values = split("[ ]?,[ ]?", $values);
$this->_values = $values;
}
if (is_array($values)) {
$this->_values = $values;} else {
$this->_values = array($values);} ... [/originalcode] if $value is a string it becames an array after the split. So the next if/else is always true ($this->_values = $values; //is execute twice) and the else clause will never process. I think this is the problem with the "comma options". In my case I've resolved it putting an additional check: [mycode] if ( (is_string($values)) && ($this->getmultiple())) {
$values = split("[ ]?,[ ]?", $values);
}
if (is_array($values)) {
$this->_values = $values;} else {
$this->_values = array($values);} [/mycode] Could be a solution or have I missed something? Thanks Saurin Emiliano P.S. sorry for my crap english :/