cvs: php4 /pear/HTML Form.php
| From: | Stig Bakken | Date: | Sun, 15 Oct 2000 02:20:39 +0000 |
| Subject: | cvs: php4 /pear/HTML Form.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2058@lists.php.net to get a copy of this message | ||
ssb Sat Oct 14 19:20:39 2000 EDT
Modified files:
/php4/pear/HTML Form.php
Log:
PEAR HTML_Form: select boxes now handles both scalars, arrays and
assoc. arrays in default value
Index: php4/pear/HTML/Form.php
diff -u php4/pear/HTML/Form.php:1.4 php4/pear/HTML/Form.php:1.5
--- php4/pear/HTML/Form.php:1.4 Sat Oct 14 10:47:54 2000
+++ php4/pear/HTML/Form.php Sat Oct 14 19:20:38 2000
@@ -17,7 +17,7 @@
// | Urs Gehrig <urs@circle.ch> |
// +----------------------------------------------------------------------+
//
-// $Id: Form.php,v 1.4 2000/10/14 17:47:54 ssb Exp $
+// $Id: Form.php,v 1.5 2000/10/15 02:20:38 ssb Exp $
//
// HTML form utility functions.
//
@@ -59,12 +59,12 @@
// {{{ constructor
function HTML_Form($action, $method = 'GET', $name = '', $target =
'') {
- $this->action = $action;
- $this->method = $method;
- $this->name = $name;
- $this->fields = array();
- $this->encoding = '';
- $this->target = $target;
+ $this->action = $action;
+ $this->method = $method;
+ $this->name = $name;
+ $this->fields = array();
+ $this->encoding = '';
+ $this->target = $target;
}
// }}}
@@ -477,9 +477,16 @@
}
while (list($val, $text) = each($entries)) {
$str .= ' <OPTION ';
- if ($default && $default == $val) {
- $str .= 'SELECTED ';
- }
+ if ($default) {
+ if ($multiple && is_array($default)) {
+ if ((is_string(key($default)) && $default[$val]) ||
+ (is_int(key($default)) && in_array($val, $default))) {
+ $str .= 'SELECTED ';
+ }
+ } elseif ($default == $val) {
+ $str .= 'SELECTED ';
+ }
+ }
$str .= "VALUE=\"$val\">$text\n";
}
$str .= " </SELECT>\n";
@@ -626,4 +633,10 @@
// }}}
}
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
?>