diff --git a/CHANGE.md b/CHANGE.md index c7b4e24..1b27f98 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,12 @@ Change Log: `yii2-widget-select2` ================================= +## Version 2.1.6 + +**Date:** 01-Nov-2019 + +- (enh #298, #289): Fix empty options when placeholder is set. + ## Version 2.1.5 **Date:** 31-Oct-2019 diff --git a/src/Select2.php b/src/Select2.php index 708b2c7..bf41edf 100644 --- a/src/Select2.php +++ b/src/Select2.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; @@ -236,8 +236,9 @@ public function renderWidget() if (empty($this->data)) { $emptyValue = !isset($this->value) || $this->value === ''; $emptyInitText = !isset($this->initValueText) || $this->initValueText === ''; + $emptyPH = !isset($this->pluginOptions['placeholder']); if ($emptyValue && $emptyInitText) { - $this->data = ['' => '']; + $this->data = $emptyPH ? ['' => ''] : []; } else { if ($multiple) { $key = !$emptyValue && is_array($this->value) ? $this->value : []; @@ -245,7 +246,7 @@ public function renderWidget() $key = !$emptyValue ? $this->value : ''; } $val = !$emptyInitText ? $this->initValueText : $key; - $this->data = $multiple ? array_combine((array)$key, (array)$val) : [$key => $val]; + $this->data = $multiple ? array_combine((array)$key, (array)$val) : (($emptyPH && $key !== '') ? [$key => $val] : []); } } $this->initLanguage('language', true); diff --git a/src/Select2Asset.php b/src/Select2Asset.php index dad5856..aa5fe0f 100644 --- a/src/Select2Asset.php +++ b/src/Select2Asset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/Select2KrajeeAsset.php b/src/Select2KrajeeAsset.php index c5724ac..1c8ced4 100644 --- a/src/Select2KrajeeAsset.php +++ b/src/Select2KrajeeAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeAsset.php b/src/ThemeAsset.php index 6756e3d..cd278ed 100644 --- a/src/ThemeAsset.php +++ b/src/ThemeAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeBootstrapAsset.php b/src/ThemeBootstrapAsset.php index 33dfdec..d5612f8 100644 --- a/src/ThemeBootstrapAsset.php +++ b/src/ThemeBootstrapAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeClassicAsset.php b/src/ThemeClassicAsset.php index 18c55fb..64f1445 100644 --- a/src/ThemeClassicAsset.php +++ b/src/ThemeClassicAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeDefaultAsset.php b/src/ThemeDefaultAsset.php index 3fd1c0b..f3decc0 100644 --- a/src/ThemeDefaultAsset.php +++ b/src/ThemeDefaultAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeKrajeeAsset.php b/src/ThemeKrajeeAsset.php index 28df727..df5c14a 100644 --- a/src/ThemeKrajeeAsset.php +++ b/src/ThemeKrajeeAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeKrajeeBs4Asset.php b/src/ThemeKrajeeBs4Asset.php index deef292..d17178a 100644 --- a/src/ThemeKrajeeBs4Asset.php +++ b/src/ThemeKrajeeBs4Asset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; diff --git a/src/ThemeMaterialAsset.php b/src/ThemeMaterialAsset.php index 1580118..334e159 100644 --- a/src/ThemeMaterialAsset.php +++ b/src/ThemeMaterialAsset.php @@ -4,7 +4,7 @@ * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 * @package yii2-widgets * @subpackage yii2-widget-select2 - * @version 2.1.5 + * @version 2.1.6 */ namespace kartik\select2; @@ -14,7 +14,7 @@ * * @author Mohamad Faeez * @modified Kartik Visweswaran - * @since 2.1.5 + * @since 2.1.6 */ class ThemeMaterialAsset extends ThemeAsset { diff --git a/src/assets/css/select2-addl.css b/src/assets/css/select2-addl.css index 3233b1b..ca8a050 100644 --- a/src/assets/css/select2-addl.css +++ b/src/assets/css/select2-addl.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Additional CSS for Select2 for extra functionalities added by Krajee * diff --git a/src/assets/css/select2-addl.min.css b/src/assets/css/select2-addl.min.css index 0c3bb19..48f1860 100644 --- a/src/assets/css/select2-addl.min.css +++ b/src/assets/css/select2-addl.min.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Additional CSS for Select2 for extra functionalities added by Krajee * diff --git a/src/assets/css/select2-krajee-bs4.css b/src/assets/css/select2-krajee-bs4.css index 1d74886..86e420a 100644 --- a/src/assets/css/select2-krajee-bs4.css +++ b/src/assets/css/select2-krajee-bs4.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Krajee Bootstrap 4.x Theme for Select2 * diff --git a/src/assets/css/select2-krajee-bs4.min.css b/src/assets/css/select2-krajee-bs4.min.css index cec5dfb..6aff847 100644 --- a/src/assets/css/select2-krajee-bs4.min.css +++ b/src/assets/css/select2-krajee-bs4.min.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Krajee Bootstrap 4.x Theme for Select2 * diff --git a/src/assets/css/select2-krajee.css b/src/assets/css/select2-krajee.css index 3aa7c00..87f8db4 100644 --- a/src/assets/css/select2-krajee.css +++ b/src/assets/css/select2-krajee.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Krajee Bootstrap 3.x Theme for Select2 * diff --git a/src/assets/css/select2-krajee.min.css b/src/assets/css/select2-krajee.min.css index a2bd268..e6f15b9 100644 --- a/src/assets/css/select2-krajee.min.css +++ b/src/assets/css/select2-krajee.min.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Krajee Bootstrap 3.x Theme for Select2 * diff --git a/src/assets/css/select2-material.css b/src/assets/css/select2-material.css index cb6cf44..cee17da 100644 --- a/src/assets/css/select2-material.css +++ b/src/assets/css/select2-material.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Material Theme for Select2 * diff --git a/src/assets/css/select2-material.min.css b/src/assets/css/select2-material.min.css index fe4aa92..e4563e9 100644 --- a/src/assets/css/select2-material.min.css +++ b/src/assets/css/select2-material.min.css @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Material Theme for Select2 * diff --git a/src/assets/js/select2-krajee.js b/src/assets/js/select2-krajee.js index 72aff1a..2296774 100644 --- a/src/assets/js/select2-krajee.js +++ b/src/assets/js/select2-krajee.js @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Additional enhancements for Select2 widget extension for Yii 2.0. * diff --git a/src/assets/js/select2-krajee.min.js b/src/assets/js/select2-krajee.min.js index 3c8b3af..0e498fb 100644 --- a/src/assets/js/select2-krajee.min.js +++ b/src/assets/js/select2-krajee.min.js @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2019 - * @version 2.1.5 + * @version 2.1.6 * * Additional enhancements for Select2 widget extension for Yii 2.0. *