PHPackages                             somov/yii2-select2-widget - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. somov/yii2-select2-widget

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

somov/yii2-select2-widget
=========================

Select 2 jQuery plugin for Yii2 with Bootstrap theme capabilities

0.1.2.1(4y ago)09BSD-3-ClauseCSS

Since Jul 20Pushed 4y agoCompare

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

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

Select2 Widget for Yii2
=======================

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

[![Latest Version](https://camo.githubusercontent.com/56228d5365db333c8f70384d118b29a6901f3e0b3df59671ae7c6ce2a40d1889/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f32616d69676f732f796969322d73656c656374322d7769646765742e7376673f7374796c653d666c61742d737175617265)](https://github.com/2amigos/yii2-select2-widget/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/69b6bb7143993cd87f45ce65e257d2519e9b760b8fec1f9c9c1b1ae1dfa85e2c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f32616d69676f732f796969322d73656c656374322d7769646765742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/2amigos/yii2-select2-widget)[![Coverage Status](https://camo.githubusercontent.com/f28602eb51350c815dc3f481a03f5666a7fc433630ebd81d04c2cd09b78019f8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f32616d69676f732f796969322d73656c656374322d7769646765742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/2amigos/yii2-select2-widget/code-structure)[![Quality Score](https://camo.githubusercontent.com/2b96f552fbc4780736dea03d3fa2a447b68b1388564523f4c25fb97d42c5498a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f32616d69676f732f796969322d73656c656374322d7769646765742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/2amigos/yii2-select2-widget)[![Total Downloads](https://camo.githubusercontent.com/e069c06ef90b3d4fe68af70f63f509834f445dd839d5a03a47075c85253f7b6c/68747470733a2f2f706f7365722e707567782e6f72672f32616d69676f732f796969322d73656c656374322d7769646765742f646f776e6c6f616473)](https://packagist.org/packages/2amigos/yii2-select2-widget)

[Select2](https://select2.github.io/) gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.

Install
-------

[](#install)

Via Composer

```
$ composer require 2amigos/yii2-select2-widget
```

Usage
-----

[](#usage)

The Widget comes in two flavors, one for the classic and the bootstrap. The widgets, apart from the bootstrap one that requires some tweaks, are mostly configured throughout the `clientOptions` and `clientEvents`. Attributes that hold the configuration of the plugin and its events respectively.

For that reason, we highly recommend you to visit the [Select2 Documentation](https://select2.github.io/options.html) for the possible options available on Select2 and [Select2 Bootstrap Theme](https://select2.github.io/select2-bootstrap-theme/4.0.3.html) to check all the possible display options regarding Select2 with this theme.

> **Note** We are in the process to create a website that will demo all our widgets, including this. The following are some basic samples to get you started. On the website, demos will be extensive and showing all possible configuration options.

### Using Select2Widget

[](#using-select2widget)

```
use dosamigos\select2\Select2:

// with \yii\bootstrap\ActiveForm;
echo $form
    ->field($model, 'attribute')
    ->widget(
        Select2::class,
        [
            'items' => $data, // $data should be the same as the items provided to a regular yii2 dropdownlist
            'clientOptions' => ['theme' => 'classic']
        ]
    );

// as widget
echo Select2::widget([
    'name' => 'my-name',
    'value' => 'my-value',
    'clientOptions' => [
        'maximumInputLength' => 20
    ]
]);
```

### Using Select2BootstrapWidget

[](#using-select2bootstrapwidget)

```
use dosamigos\select2\Select2Bootstrap:

// displaying the select2 with prepended addon
echo $form
    ->field($model, 'attribute')
    ->widget(
        Select2Bootstrap::class,
        [
            'items' => $data, // $data should be the same as the items provided to a regular yii2 dropdownlist
            'template' => '' .
                  '' .
                  '' .
                  'State' .
                  '' .
                  '' .
                  '{input}' .
                   'Append' .
                   ''
        ]
    );

// as widget
echo Select2Bootstrap::widget([
    'name' => 'my-name',
    'value' => 'my-value',
    'clientOptions' => [
        'maximumInputLength' => 20
    ]
]);
```

Testing
-------

[](#testing)

```
$ phpunit
```

Using code fixer
----------------

[](#using-code-fixer)

We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.

```
./vendor/bin/php-cs-fixer fix ./src --config .php_cs
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [2amigos](https://github.com/2amigos)
- [All Contributors](../../contributors)

License
-------

[](#license)

The BSD License (BSD). Please see [License File](LICENSE.md) for more information.

> [![](https://camo.githubusercontent.com/9fd8f1de41dc23003bb2a54034cb6658dde5be97092e195a62d629d0d7fa7f6c/687474703a2f2f7777772e67726176617461722e636f6d2f6176617461722f35353336333339346437323934356666376564333132353536656330343165302e706e67)](http://www.2amigos.us)
>  *Custom Software | Web &amp; Mobile Development*
>  [www.2amigos.us](http://www.2amigos.us)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81% 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 ~257 days

Recently: every ~384 days

Total

7

Last Release

1675d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/67f8207c2de1ee090e2d3ae6168f17ae3aefb9447b6154a690ab2dc7ef163ff9?d=identicon)[somov](/maintainers/somov)

---

Top Contributors

[![tonydspaniard](https://avatars.githubusercontent.com/u/566016?v=4)](https://github.com/tonydspaniard "tonydspaniard (17 commits)")[![somov](https://avatars.githubusercontent.com/u/6071978?v=4)](https://github.com/somov "somov (4 commits)")

---

Tags

pluginjqueryyii2extensionwidgetformdropdownselect22amigos

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  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-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)
