PHPackages                             kartik-v/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. [Templating &amp; Views](/categories/templating)
4. /
5. kartik-v/yii2-widget-select2

ActiveYii2-extension[Templating &amp; Views](/categories/templating)

kartik-v/yii2-widget-select2
============================

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

v2.2.5(2y ago)3279.7M↓14.4%144[8 issues](https://github.com/kartik-v/yii2-widget-select2/issues)[1 PRs](https://github.com/kartik-v/yii2-widget-select2/pulls)20BSD-3-ClauseCSS

Since Nov 8Pushed 1y ago17 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (29)Used By (20)

 [ ![Krajee Logo](https://camo.githubusercontent.com/4addfbb3869c3fc7d79befea4f06d9cf3655a686fb503df0da1d725859cfdef9/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f6b72616a65652d6c6f676f2d622e706e67) ](http://demos.krajee.com "Krajee Demos")
 yii2-widget-select2 ---

 [![Donate](https://camo.githubusercontent.com/0336bc43d88554a3f2d6c74dddf312bc2c65c2eacca70d83ae40f5567098d00e/68747470733a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal") [![kartikv](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/kartikv "Buy me a coffee")
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------yii2-widget-select2------------------)

[![Financial Contributors on Open Collective](https://camo.githubusercontent.com/bddb299bf6cb17fd7d3b9f0dabfe0195fc3a1be891537497ca744b5e5bdec6e7/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f616c6c2f62616467652e7376673f6c6162656c3d66696e616e6369616c2b636f6e7472696275746f7273)](https://opencollective.com/yii2-widget-select2)[![Stable Version](https://camo.githubusercontent.com/972f9ee44250be8bd0b203aabc266c328e1b5dc5df56f2de6cf9418bb6e80e9d/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-widget-select2)[![Unstable Version](https://camo.githubusercontent.com/7d0a27411889b24813fc1a4717f4fd8e10cec71adbe2a49647b6e6c24a7aac87/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d73656c656374322f762f756e737461626c65)](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.

Release Changes
---------------

[](#release-changes)

> NOTE: Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-select2/blob/master/CHANGE.md) for details on changes to various releases.

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.

Documentation and Demo
----------------------

[](#documentation-and-demo)

You can refer detailed [documentation and demos](http://demos.krajee.com/widget-details/select2) and [API Code Documentation](https://docs.krajee.com/kartik-select2-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 ...']
]);
```

Contributors
------------

[](#contributors)

### Code Contributors

[](#code-contributors)

This project exists thanks to all the people who contribute. \[[Contribute](.github/CONTRIBUTING.md)\]. [![](https://camo.githubusercontent.com/751b800748ff44eb776bab7c6c7a1a2a5de8ce07604d1e19e2dd16254e3acd39/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/kartik-v/yii2-widget-select2/graphs/contributors)

### Financial Contributors

[](#financial-contributors)

Become a financial contributor and help us sustain our community. \[[Contribute](https://opencollective.com/yii2-widget-select2/contribute)\]

#### Individuals

[](#individuals)

[![](https://camo.githubusercontent.com/e546ffb2763bf4ab514a609f493c1d2d868cdb8594a64d8267bf152cf676f45c/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f696e646976696475616c732e7376673f77696474683d383930)](https://opencollective.com/yii2-widget-select2)

#### Organizations

[](#organizations)

Support this project with your organization. Your logo will show up here with a link to your website. \[[Contribute](https://opencollective.com/yii2-widget-select2/contribute)\]

[![](https://camo.githubusercontent.com/f23e58324e55abfef524c00faff7fec0bf63302abb8781c7efd89d95f9e11e98/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f302f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/0/website)[![](https://camo.githubusercontent.com/9914baa4ae80ae6ba41dc48869e21d2dc53717f9033ddacd1b1eaba0ee4cb900/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f312f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/1/website)[![](https://camo.githubusercontent.com/e989fae4450e3204c70fb1639cadb0a42c555b09d1c71ef13da6cd7a3442b69c/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f322f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/2/website)[![](https://camo.githubusercontent.com/829dc61a8ff7698e389b5332c180b6b33e944b667378c03c00f6b2203fbf6701/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f332f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/3/website)[![](https://camo.githubusercontent.com/644f1b6e6383f202ec609a7ebdaf84b9379c32972b96ad6589a936fecb018222/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f342f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/4/website)[![](https://camo.githubusercontent.com/d82105b71f15f78073e551bfedff8ba5a6d4b66f4ffd8cd9b931f16620278e03/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f352f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/5/website)[![](https://camo.githubusercontent.com/5b0308956a9da7f69b498a5d9bd52c278ec1f8428e9f3095079f6b21a869847d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f362f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/6/website)[![](https://camo.githubusercontent.com/a8d3b13e1cb6cd5651b491a775a16b26017e410e0dfb214397be4edbc4dc82e2/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f372f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/7/website)[![](https://camo.githubusercontent.com/59e1921859a21b20515ccf7c6de8f5ec1d00cc737b7ef0ce318a59697c23dc7d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f382f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/8/website)[![](https://camo.githubusercontent.com/956d734dfa2ee0461548b65dafa593d5f4101966d5fc6c3d44e7b29fdb26b802/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d7769646765742d73656c656374322f6f7267616e697a6174696f6e2f392f6176617461722e737667)](https://opencollective.com/yii2-widget-select2/organization/9/website)

License
-------

[](#license)

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

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity66

Solid adoption and visibility

Community51

Growing community involvement

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 75.4% 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 ~116 days

Recently: every ~185 days

Total

28

Last Release

1061d ago

Major Versions

v1.0.1 → v2.0.02015-05-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3592619?v=4)[Kartik Visweswaran](/maintainers/kartik-v)[@kartik-v](https://github.com/kartik-v)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (147 commits)")[![vishuB](https://avatars.githubusercontent.com/u/13677102?v=4)](https://github.com/vishuB "vishuB (10 commits)")[![Shaposhnikov](https://avatars.githubusercontent.com/u/2725815?v=4)](https://github.com/Shaposhnikov "Shaposhnikov (5 commits)")[![DrmagicE](https://avatars.githubusercontent.com/u/13395096?v=4)](https://github.com/DrmagicE "DrmagicE (3 commits)")[![dogrocker](https://avatars.githubusercontent.com/u/8379027?v=4)](https://github.com/dogrocker "dogrocker (3 commits)")[![syedmuneer](https://avatars.githubusercontent.com/u/19424588?v=4)](https://github.com/syedmuneer "syedmuneer (2 commits)")[![digitv](https://avatars.githubusercontent.com/u/11768817?v=4)](https://github.com/digitv "digitv (2 commits)")[![joshuatam](https://avatars.githubusercontent.com/u/297250?v=4)](https://github.com/joshuatam "joshuatam (1 commits)")[![kenjebaev](https://avatars.githubusercontent.com/u/20373911?v=4)](https://github.com/kenjebaev "kenjebaev (1 commits)")[![ktropp](https://avatars.githubusercontent.com/u/40465144?v=4)](https://github.com/ktropp "ktropp (1 commits)")[![kullarkert](https://avatars.githubusercontent.com/u/195263?v=4)](https://github.com/kullarkert "kullarkert (1 commits)")[![linkaixiang4883](https://avatars.githubusercontent.com/u/28226678?v=4)](https://github.com/linkaixiang4883 "linkaixiang4883 (1 commits)")[![maxxer](https://avatars.githubusercontent.com/u/240201?v=4)](https://github.com/maxxer "maxxer (1 commits)")[![mfaeezmazlan](https://avatars.githubusercontent.com/u/14104634?v=4)](https://github.com/mfaeezmazlan "mfaeezmazlan (1 commits)")[![nazakar](https://avatars.githubusercontent.com/u/11972646?v=4)](https://github.com/nazakar "nazakar (1 commits)")[![niki7har](https://avatars.githubusercontent.com/u/17407292?v=4)](https://github.com/niki7har "niki7har (1 commits)")[![nikosid](https://avatars.githubusercontent.com/u/1609434?v=4)](https://github.com/nikosid "nikosid (1 commits)")[![nurielmeni](https://avatars.githubusercontent.com/u/662907?v=4)](https://github.com/nurielmeni "nurielmeni (1 commits)")[![RangelReale](https://avatars.githubusercontent.com/u/369785?v=4)](https://github.com/RangelReale "RangelReale (1 commits)")[![RomeroMsk](https://avatars.githubusercontent.com/u/4639951?v=4)](https://github.com/RomeroMsk "RomeroMsk (1 commits)")

---

Tags

pluginjqueryyii2extensionwidgetformdropdownselect2

### Embed Badge

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

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

###  Alternatives

[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)[kartik-v/yii2-widget-rating

A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)

444.1M8](/packages/kartik-v-yii2-widget-rating)

PHPackages © 2026

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