Merge pull request #2011 from creocoder/activedropdownlist-fix

Html::activeDropDownList() and 'multiple' option fix
This commit is contained in:
Qiang Xue
2014-01-16 19:40:31 -08:00

View File

@@ -1222,6 +1222,9 @@ class BaseHtml
*/ */
public static function activeDropDownList($model, $attribute, $items, $options = []) public static function activeDropDownList($model, $attribute, $items, $options = [])
{ {
if (!empty($options['multiple'])) {
return static::activeListBox($model, $attribute, $items, $options);
}
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$selection = static::getAttributeValue($model, $attribute); $selection = static::getAttributeValue($model, $attribute);
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
@@ -1273,7 +1276,7 @@ class BaseHtml
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$selection = static::getAttributeValue($model, $attribute); $selection = static::getAttributeValue($model, $attribute);
if (!array_key_exists('unselect', $options)) { if (!array_key_exists('unselect', $options)) {
$options['unselect'] = '0'; $options['unselect'] = '';
} }
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);