PHPackages                             sangroya/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. sangroya/yii2-widget-select2

ActiveYii2-extension

sangroya/yii2-widget-select2
============================

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

0478CSS

Since Dec 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sangroya/sangroya-yii2-widget-select2)[ Packagist](https://packagist.org/packages/sangroya/yii2-widget-select2)[ RSS](/packages/sangroya-yii2-widget-select2/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

 [ ![Donate](https://camo.githubusercontent.com/4af77d425ca202e55ab3d711b438e238ded194735bc345a019ac060e03e26227/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67) ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal")
=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------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) 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

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9700282?v=4)[Parveen Sangroya](/maintainers/sangroya)[@sangroya](https://github.com/sangroya)

---

Top Contributors

[![sangroya](https://avatars.githubusercontent.com/u/9700282?v=4)](https://github.com/sangroya "sangroya (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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