summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_html.class2
-rwxr-xr-xtests/it_html.t12
2 files changed, 13 insertions, 1 deletions
diff --git a/it_html.class b/it_html.class
index f7bff0e..35eb273 100644
--- a/it_html.class
+++ b/it_html.class
@@ -347,7 +347,7 @@ function select($tags, $options, $selected = null)
}
}
- $selected = (isset($selected) && !is_array($selected)) ? explode(',', $selected) : (array)$selected;
+ $selected = ($tags['multiple'] && is_string($selected)) ? explode(',', $selected) : (array)$selected;
$html = "";
foreach($options as $value => $option)
diff --git a/tests/it_html.t b/tests/it_html.t
index e87df48..b560ed1 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -38,6 +38,18 @@ is(
"link tag with data"
);
+is(
+ it::replace('\n+\s*' => "", select('name' => "gna", 'multiple' => true, '1:foo,2:bar', '1,2')),
+ '<select name="gna" multiple><option value="1" selected>foo</option><option value="2" selected>bar</option></select>',
+ "select tag with multiselect",
+);
+
+is(
+ it::replace('\n+\s*' => "", select('name' => "gna", array("1" => "foo", "2" => 'bar', '1,2' => "qux"), '1,2')),
+ '<select name="gna"><option value="1">foo</option><option value="2">bar</option><option value="1,2" selected>qux</option></select>',
+ "link tag without multiselect",
+);
+
# XML generation
unset($GLOBALS['it_html']);
new it_html(array('htmltype' => "xhtml", 'tags' => "xmltest"));