Home » HTML » HTML_QuickForm » Bug #5219
single select doest not export a value (even default) for invalid input
Details
| Submitted | 2005-08-27 12:55 UTC |
|---|---|
| From | pear at iantomey dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.3.10 |
| OS | Debian Sarge |
| Roadmaps | (Not assigned) |
Comments
[2005-08-27 12:55 UTC] pear at iantomey dot com
Description:
------------
v3.2.4pl1
if you have a select box that is not multiple-selection and the user manually concocts a query with a blank or invalid value for the select(easy to do with a get), then no value for the select is exported.
even calling setDefaults makes no difference to this - it only sets the default selection on the screen
i believe that it should return the first option in the list or the defaultValue (if set) as AFAIK no browser allows a 'no selection' option. at the very least it should return the defaultValue
this potentionally could break websites if, like me you were expecting validated results every time.
i'd change select.php, exportValue, line 568 onwards from
if (is_array($cleanValue) && !$this->getMultiple()) {
return $this->_prepareValue($cleanValue[0], $assoc);
} else {
return $this->_prepareValue($cleanValue, $assoc);
}
to
if (!$this->getMultiple()) {
if (is_array($cleanValue))
return $this->_prepareValue($cleanValue[0], $assoc);
else
return $this->_prepareValue($this->_options[0]['attr']['value'], $assoc);
} else {
return $this->_prepareValue($cleanValue, $assoc);
}
to return the 1st option, i havent looking into the default handling
cheers
ian