added the ability to have multiple selected items in form_dropdown()
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index e591eb7..a67ea05 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -221,18 +221,24 @@
* @param string
* @return string
*/
-function form_dropdown($name = '', $options = array(), $selected = '', $extra = '')
+function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
{
+ if ( ! is_array($selected))
+ {
+ $selected = array($selected);
+ }
+
if ($extra != '') $extra = ' '.$extra;
-
- $form = '<select name="'.$name.'"'.$extra.">\n";
+ $multiple = (count($selected > 1))?' multiple="multiple"':'';
+
+ $form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
foreach ($options as $key => $val)
{
$key = (string) $key;
$val = (string) $val;
- $sel = ($selected != $key) ? '' : ' selected="selected"';
+ $sel = (in_array($key, $selected))?' selected="selected"':'';
$form .= '<option value="'.$key.'"'.$sel.'>'.$val."</option>\n";
}