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

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

silentlun/yii2-widget-select2
=============================

yii2-select2

v1.0.0(10mo ago)01BSD-3-ClauseCSS

Since Jul 17Pushed 10mo agoCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

Yii2 的 Select2 小部件
==================

[](#yii2-的-select2-小部件)

Select2 jQuery 插件，用于Yii2，具有 Bootstrap 主题功能。

[Select2](https://select2.github.io/) 为您提供了一个可自定义的选择框，支持搜索、标记、远程 数据集、无限滚动和许多其他常用选项。

安装
--

[](#安装)

安装此扩展的首选方法是通过 [composer](https://getcomposer.org/download/).

运行

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

```

或添加

```
"silentlun/yii2-widget-select2": "*"

```

添加到 `composer.json` 文件的 require 部分。

用法
--

[](#用法)

您可能需要调整 `clientOptions` 和 `clientEvents` 参数。

因此，我们强烈建议您访问 [Select2 Documentation](https://select2.github.io/options.html) 文档，了解 Select2 可用的可能选项，以检查所有可能的选项 显示有关此主题的 Select2 的选项。

### 使用 Select2Widget

[](#使用-select2widget)

```
use silentlun\select2\Select2:

// with \yii\bootstrap\ActiveForm;
echo $form
    ->field($model, 'attribute')
    ->widget(
        Select2::class,
        [
            'items' => $data, // $data 应该与提供给常规 Yi2 DropdownList 的项目相同
            'options' => ['placeholder' => '选择', 'multiple' => true],
            'clientOptions' => ['theme' => 'classic']
        ]
    );

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance55

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

300d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77e448a626a78a92eee5ccb5303bbbcaae55f00e4414f769f295b4f7f72b05ad?d=identicon)[silentlun](/maintainers/silentlun)

---

Top Contributors

[![silentlun](https://avatars.githubusercontent.com/u/16114449?v=4)](https://github.com/silentlun "silentlun (2 commits)")

---

Tags

yii2extension

### Embed Badge

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

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

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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