pcrt/yii2-select2

Yii2-select2 小部件实现

1.0.4 2019-11-25 09:13 UTC

This package is not auto-updated.

Last update: 2024-09-29 21:53:01 UTC


README

Select2 提供了一个可定制的选择框,支持搜索、标记、远程数据集、无限滚动以及其他许多常用选项。

## 安装

安装此扩展的首选方式是通过 composer

运行以下命令:

$ php composer.phar require pcrt/yii2-select "*"

或将其添加到您的 composer.json 文件的 require 部分:

"pcrt/yii2-select2": "*"

```json

用法

安装扩展后,修改您的应用程序配置以包含

use pcrt\widgets\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
        ]
    );

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

许可证

Yii2-select2 在 BSD-3 许可证下发布。有关详细信息,请参阅附带的 LICENSE.md 文件。

祝您使用愉快!