PHPackages                             longman96/yii2-widget-select2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. longman96/yii2-widget-select2

ActiveYii2-extension

longman96/yii2-widget-select2
=============================

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).

v2.0.3(10y ago)0127BSD-3-ClauseJavaScript

Since Nov 8Pushed 10y ago1 watchersCompare

[ Source](https://github.com/longman96/yii2-widget-select2)[ Packagist](https://packagist.org/packages/longman96/yii2-widget-select2)[ Docs](https://github.com/kartik-v/yii2-widget-select2)[ RSS](/packages/longman96-yii2-widget-select2/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

yii2-widget-select2
===================

[](#yii2-widget-select2)

[![Latest Stable Version](https://camo.githubusercontent.com/972f9ee44250be8bd0b203aabc266c328e1b5dc5df56f2de6cf9418bb6e80e9d/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-widget-select2)[![License](https://camo.githubusercontent.com/d3bb692a19df0ca690e4510dc78248a37c423c91d5eff3ef06f5c46e1af5c13d/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f6c6963656e7365)](https://packagist.org/packages/kartik-v/yii2-widget-select2)[![Total Downloads](https://camo.githubusercontent.com/d0ee73c964c97baf6c57a2099a17c6dbdba4fb3d7252e6bbb2225824d73e396c/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f646f776e6c6f616473)](https://packagist.org/packages/kartik-v/yii2-widget-select2)[![Monthly Downloads](https://camo.githubusercontent.com/6640c2f1c6751259a65319601fe62753246130a3e1b7c09529782af6c5bf1fb4/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f642f6d6f6e74686c79)](https://packagist.org/packages/kartik-v/yii2-widget-select2)[![Daily Downloads](https://camo.githubusercontent.com/533b558bfd3f0b4c025b2c54dcf22fb9f869f77b1b8bfd72fd56934b652deb2d/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f642f6461696c79)](https://packagist.org/packages/kartik-v/yii2-widget-select2)

This is the Select2 widget and a Yii 2 enhanced wrapper for the [Select2 jQuery plugin](http://ivaynberg.github.io/select2). This input widget is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results. The widget is specially styled for Bootstrap 3 and offers a few enhancements not available in the source plugin. The widget allows graceful degradation to a normal HTML select or text input, if the browser does not support JQuery.

> NOTE: This extension is a sub repo split of [yii2-widgets](https://github.com/kartik-v/yii2-widgets). The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of [yii2-widgets](http://demos.krajee.com/widgets).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Check the [composer.json](https://github.com/kartik-v/yii2-widget-select2/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.

To install, either run

```
$ php composer.phar require kartik-v/yii2-widget-select2 "@dev"

```

or add

```
"kartik-v/yii2-widget-select2": "@dev"

```

to the `require` section of your `composer.json` file.

Latest Release
--------------

[](#latest-release)

> NOTE: The latest version of the module is v2.0.4 Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-select2/blob/master/CHANGE.md) for details.

The widget has a major version revamp with v2.0. This release includes updates to use Select2 plugin release v4.0. Select2 release v4.0 is a major rewrite over Select2 v3.x and hence quite a few enhancements or changes should be expected. To use the earlier plugin release v3.5.2, you must point it to the [v1.0.1 release](https://github.com/kartik-v/yii2-widget-select2/releases/tag/v1.0.1) of the widget.

Enhancements with release v2.0:

- New `theme` property that allows you to set themes in Select2 to style your widget.
- A brand new theme by Krajee `Select2::THEME_KRAJEE` is specially styled for Select2. This will help achieve various new yii2-widget-select2 features. This theme matches the bootstrap 3 styling with enhancements.
- Additional themes provided in form of `Select2::THEME_DEFAULT`, `Select2::THEME_CLASSIC`, and `Select2::THEME_BOOTSTRAP`. One can add their own custom theme and configure the widget.
- No more `query` plugin property needed. It is also not mandatory to configure `data` even if you have not set `tags` or `query` or `ajax`. Widget will intelligently evaluate the properties and default list values.
- Enhanced tagging support. Use it just like a multiple select but with taggable values. In addition, one can create tags on the fly.
- Enhanced ajax support. Refer the [demos](http://demos.krajee.com/widget-details/select2) for details.
- The `initSelection` method of Select2 3.5.x plugin is obsolete/removed. New `initValueText` property is been provided with the Select2 widget to cater to this (e.g. for ajax based loading).
- Ability to disable selective option values in the Select2 dropdown OR add HTML attributes to selective options.
- Enhancement by Krajee to disable the search box to use like a normal select.
- Enhancements to locales and translations. Allow multiple language Select2 widgets on the same page.

Demo
----

[](#demo)

You can refer detailed [documentation and demos](http://demos.krajee.com/widget-details/select2) on usage of the extension.

Usage
-----

[](#usage)

```
use kartik\select2\Select2;

// Normal select with ActiveForm & model
echo $form->field($model, 'state_1')->widget(Select2::classname(), [
    'data' => $data,
    'language' => 'de',
    'options' => ['placeholder' => 'Select a state ...'],
    'pluginOptions' => [
        'allowClear' => true
    ],
]);

// Multiple select without model
echo Select2::widget([
    'name' => 'state_2',
    'value' => '',
    'data' => $data,
    'options' => ['multiple' => true, 'placeholder' => 'Select states ...']
]);
```

License
-------

[](#license)

**yii2-widget-select2** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 77.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~33 days

Total

6

Last Release

3894d ago

Major Versions

v1.0.1 → v2.0.02015-05-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/17ae5f66d812085259df545ac8d6240bf26e6db9c02ce40c098784b990b5c254?d=identicon)[longman96](/maintainers/longman96)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (37 commits)")[![longman96](https://avatars.githubusercontent.com/u/11771982?v=4)](https://github.com/longman96 "longman96 (10 commits)")[![RangelReale](https://avatars.githubusercontent.com/u/369785?v=4)](https://github.com/RangelReale "RangelReale (1 commits)")

---

Tags

pluginjqueryyii2extensionwidgetformdropdownselect2

### Embed Badge

![Health badge](/badges/longman96-yii2-widget-select2/health.svg)

```
[![Health](https://phpackages.com/badges/longman96-yii2-widget-select2/health.svg)](https://phpackages.com/packages/longman96-yii2-widget-select2)
```

###  Alternatives

[kartik-v/yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).

3279.7M191](/packages/kartik-v-yii2-widget-select2)[kartik-v/yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).

1097.0M60](/packages/kartik-v-yii2-widget-datepicker)[kartik-v/yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)

1036.5M47](/packages/kartik-v-yii2-widget-datetimepicker)[kartik-v/yii2-widget-depdrop

Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets)

814.9M18](/packages/kartik-v-yii2-widget-depdrop)[kartik-v/yii2-widget-typeahead

Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).

454.8M9](/packages/kartik-v-yii2-widget-typeahead)[kartik-v/yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 3.x, 4.x &amp; 5.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

2286.8M95](/packages/kartik-v-yii2-widget-fileinput)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
