cvs: pear /HTML_QuickForm/QuickForm select.php
| From: | Bertrand Mansion | Date: | Fri, 14 Jun 2002 13:16:20 +0000 |
| Subject: | cvs: pear /HTML_QuickForm/QuickForm select.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4615@lists.php.net to get a copy of this message | ||
mansion Fri Jun 14 09:16:20 2002 EDT
Modified files:
/pear/HTML_QuickForm/QuickForm select.php
Log:
Improvements in the use of select elements when set to multiple and in html display when they are
frozen.
Index: pear/HTML_QuickForm/QuickForm/select.php
diff -u pear/HTML_QuickForm/QuickForm/select.php:1.8 pear/HTML_QuickForm/QuickForm/select.php:1.9
--- pear/HTML_QuickForm/QuickForm/select.php:1.8 Fri Jun 7 15:32:55 2002
+++ pear/HTML_QuickForm/QuickForm/select.php Fri Jun 14 09:16:20 2002
@@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: select.php,v 1.8 2002/06/07 19:32:55 jrust Exp $
+// $Id: select.php,v 1.9 2002/06/14 13:16:20 mansion Exp $
require_once('DB.php');
require_once('HTML/QuickForm/element.php');
@@ -73,8 +73,8 @@
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'select';
- if ($this->getAttribute('multiple') &&
strpos($elementName,']') < 2) {
- $this->setName($elementName.'[]');
+ if ($this->getAttribute('multiple')) {
+ $this->setMultiple(true);
}
if (isset($options)) {
$this->load($options);
@@ -279,7 +279,7 @@
*/
function getMultiple()
{
- return $this->getAttribute("multiple");
+ return $this->getAttribute('multiple');
} //end func getMultiple
// }}}
@@ -300,13 +300,13 @@
function addOption($text, $value, $attributes=null)
{
$attributes = $this->_parseAttributes($attributes);
- if ($this->getAttribute("selected") && !in_array($value,
$this->_values)) {
+ if ($this->getAttribute('selected') && !in_array($value,
$this->_values)) {
$this->_values[] = $value;
array_unique($this->_values);
}
- $attr = array("value"=>$value);
+ $attr = array('value'=>$value);
$this->_updateAttrArray($attributes, $attr);
- $this->_options[] = array("text"=>$text, "attr"=>$attributes);
+ $this->_options[] = array('text'=>$text, 'attr'=>$attributes);
} // end func addOption
// }}}
@@ -501,7 +501,6 @@
*/
function getFrozenHtml()
{
- // Fix me : doesn't work for multiple.
$value = '';
if (is_array($this->_values)) {
foreach ($this->_values as $key => $val) {
@@ -523,12 +522,12 @@
}
}
if (is_array($value)) {
- $html = join(', ', $value);
+ $html = join('<br />', $value);
if ($this->_persistantFreeze) {
$name = $this->getName();
- foreach ($value as $item) {
+ foreach ($value as $key => $item) {
$html .= '<input type="hidden" name="' .
- $name . '" value="' . $this->_values[0] .
'" />';
+ $name . '" value="' . $this->_values[$key] .
'" />';
}
}
} else {
@@ -548,4 +547,4 @@
// }}}
} //end class HTML_QuickForm_select
-?>
+?>
\ No newline at end of file