PHPackages                             khotim/yii2-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. [Framework](/categories/framework)
4. /
5. khotim/yii2-select2

ActiveYii2-extension[Framework](/categories/framework)

khotim/yii2-select2
===================

Select2 extension for the Yii framework

v1.0(10y ago)290MITJavaScriptPHP &gt;=5.4.0

Since Mar 2Pushed 8y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

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

[](#yii2-select2)

Yii2 Select2 is an input widget extends from `\yii\widgets\inputWidget` which uses the ability of [Select2 plugin](https://select2.github.io/).

[![Latest Stable Version](https://camo.githubusercontent.com/2d1f682abd57c9e0b9743e5246268f624d0e57b038cf6344e9c0c04912dca236/68747470733a2f2f706f7365722e707567782e6f72672f6b686f74696d2f796969322d73656c656374322f762f737461626c65)](https://packagist.org/packages/khotim/yii2-select2)[![License](https://camo.githubusercontent.com/54296c54d296ca531fdd83f0c6e07232293da3d6f55ca1bf239f7f01d20c4b24/68747470733a2f2f706f7365722e707567782e6f72672f6b686f74696d2f796969322d73656c656374322f6c6963656e7365)](https://packagist.org/packages/khotim/yii2-select2)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist khotim/yii2-select2 "*"

```

or add

```
"khotim/yii2-select2": "*"

```

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

Usage
-----

[](#usage)

This extension is similar to `Html::dropDownList()` except that a text input will be used to search the available option list from a data source. The minimum usage using prepared array is

```
echo \khotim\select2\Select2::widget([
    'name' => 'option_list',
    'data' => [
        0 => 'enhancement',
        1 => 'bug',
        2 => 'duplicate',
        3 => 'invalid',
        4 => 'wontfix'
    ],
]);
```

You can also attach this extension in an ActiveField by configuring its `widget()` method like this

```
