Skip to content

Commit

Permalink
Enable multiple selects
Browse files Browse the repository at this point in the history
  • Loading branch information
bloatware committed Apr 30, 2016
1 parent d49fc7c commit da34479
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions textpattern/lib/txplib_forms.php
Expand Up @@ -134,10 +134,16 @@ function selectInput($name = '', $array = array(), $value = '', $blank_first = f
$out = array();

$selected = false;
$value = (string) $value;
$multiple = is_array($value) ? ' multiple="multiple"' : '';

if ($multiple) {
$name .= '[]';
} else {
$value = (string) $value;
}

foreach ($array as $avalue => $alabel) {
if ($value === (string) $avalue) {
if (!$multiple && $value === (string) $avalue || $multiple && in_array($avalue, $value)) {
$sel = ' selected="selected"';
$selected = true;
} else {
Expand All @@ -163,7 +169,7 @@ function selectInput($name = '', $array = array(), $value = '', $blank_first = f
$atts .= ' '.trim($onchange);
}

return n.'<select'.$atts.'>'.n.join(n, $out).n.'</select>'; // TODO: use jQuery UI selectmenu?
return n.'<select'.$atts.$multiple.'>'.n.join(n, $out).n.'</select>'; // TODO: use jQuery UI selectmenu?
}

/**
Expand Down

0 comments on commit da34479

Please sign in to comment.