44 * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021
55 * @package yii2-widgets
66 * @subpackage yii2-widget-select2
7- * @version 2.2.1
7+ * @version 2.2.2
88 */
99
1010namespace kartik \select2 ;
2525/**
2626 * Select2 widget is a Yii2 wrapper for the Select2 jQuery plugin. This input widget is a jQuery based replacement for
2727 * select boxes. It supports searching, remote data sets, and infinite scrolling of results. The widget is specially
28- * styled for Bootstrap 3.x and Bootstrap 4 .x.
28+ * styled for all major Bootstrap releases 3.x, 4.x & 5 .x.
2929 *
3030 * @author Kartik Visweswaran <[email protected] > 3131 * @since 1.0
@@ -89,7 +89,7 @@ class Select2 extends InputWidget
8989 /**
9090 * @var string the theme name to be used for styling the Select2. If not set this will default to:
9191 * - [[THEME_KRAJEE]] if [[bsVersion]] is set to '3.x'
92- * - [[THEME_KRAJEE_BS4]] if [[bsVersion]] is set to '4.x'
92+ * - [[THEME_KRAJEE_BS4]] if [[bsVersion]] is set to '4.x' or '5.x'
9393 */
9494 public $ theme ;
9595
@@ -218,7 +218,8 @@ public function run()
218218 public function renderWidget ()
219219 {
220220 if (!isset ($ this ->theme )) {
221- $ this ->theme = $ this ->isBs4 () ? self ::THEME_KRAJEE_BS4 : self ::THEME_KRAJEE ;
221+ $ ver = $ this ->getBsVer ();
222+ $ this ->theme = $ ver === 3 ? self ::THEME_KRAJEE : self ::THEME_KRAJEE_BS4 ;
222223 }
223224 $ this ->initI18N (__DIR__ );
224225 $ this ->pluginOptions ['theme ' ] = $ this ->theme ;
@@ -280,7 +281,7 @@ protected function renderToggleAll()
280281 }
281282 $ unchecked = '<i class="glyphicon glyphicon-unchecked"></i> ' ;
282283 $ checked = '<i class="glyphicon glyphicon-check"></i> ' ;
283- if ($ this ->isBs4 ( )) {
284+ if (! $ this ->isBs ( 3 )) {
284285 $ unchecked = '<i class="far fa-square"></i> ' ;
285286 $ checked = '<i class="far fa-check-square"></i> ' ;
286287 }
@@ -350,7 +351,7 @@ protected function embedAddon($input)
350351 if (empty ($ this ->addon )) {
351352 return $ input ;
352353 }
353- $ isBs4 = $ this ->isBs4 ( );
354+ $ notBs3 = ! $ this ->isBs ( 3 );
354355 $ group = ArrayHelper::getValue ($ this ->addon , 'groupOptions ' , []);
355356 $ css = ['input-group ' , 's2-input-group ' ];
356357 if (isset ($ this ->size )) {
@@ -361,12 +362,12 @@ protected function embedAddon($input)
361362 Html::addCssClass ($ group , 'kv-input-group-hide ' );
362363 Html::addCssClass ($ group , 'group- ' . $ this ->options ['id ' ]);
363364 }
364- $ prepend = $ this ->getAddonContent ('prepend ' , $ isBs4 );
365- $ append = $ this ->getAddonContent ('append ' , $ isBs4 );
366- if (!$ isBs4 && isset ($ this ->addon ['prepend ' ]) && is_array ($ this ->addon ['prepend ' ])) {
365+ $ prepend = $ this ->getAddonContent ('prepend ' );
366+ $ append = $ this ->getAddonContent ('append ' );
367+ if (!$ notBs3 && isset ($ this ->addon ['prepend ' ]) && is_array ($ this ->addon ['prepend ' ])) {
367368 Html::addCssClass ($ group , 'select2-bootstrap-prepend ' );
368369 }
369- if (!$ isBs4 && isset ($ this ->addon ['append ' ]) && is_array ($ this ->addon ['append ' ])) {
370+ if (!$ notBs3 && isset ($ this ->addon ['append ' ]) && is_array ($ this ->addon ['append ' ])) {
370371 Html::addCssClass ($ group , 'select2-bootstrap-append ' );
371372 }
372373 $ addonText = $ prepend . $ input . $ append ;
0 commit comments