diff options
Diffstat (limited to 'system/helpers')
-rw-r--r-- | system/helpers/form_helper.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index e591eb74c..a67ea050d 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -221,18 +221,24 @@ function form_textarea($data = '', $value = '', $extra = '') * @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";
}
|