2amigos / yii2-select2-widget
此软件包已被废弃,不再维护。没有推荐替代软件包。
具有Bootstrap主题能力的Yii2 Select 2 jQuery插件
0.1.2
2017-07-26 15:34 UTC
Requires
- bower-asset/select2: ~4.0
- bower-asset/select2-bootstrap-theme: ~0.1.0-beta.10
- yiisoft/yii2: ~2.0.5
- yiisoft/yii2-bootstrap: ~2.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpmd/phpmd: @stable
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: *
This package is auto-updated.
Last update: 2023-08-16 03:13:12 UTC
README
Select2提供具有搜索、标签、远程数据集、无限滚动和许多其他常用选项的自定义选择框。
安装
通过Composer
$ composer require 2amigos/yii2-select2-widget
使用方法
小部件有两种风格,一种是经典风格,一种是Bootstrap风格。除了Bootstrap风格需要一些调整外,小部件的配置主要通过clientOptions
和clientEvents
完成。这些属性分别用于保存插件的配置和其事件。
因此,我们强烈建议您访问Select2文档以查看Select2提供的可能选项,以及Select2 Bootstrap主题以查看有关Select2的显示选项。
注意 我们正在创建一个网站,将在其中展示所有小部件,包括这个。以下是一些基本示例以帮助您入门。在网站上,演示将更全面,显示所有可能的配置选项。
使用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 ] ]);
使用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' => '<div class="input-group">' . '<span class="input-group-btn">' . '<button class="btn btn-default" type="button" data-select2-open="multi-prepend-append">' . 'State' . '</button>' . '</span>' . '{input}' . '<span class="input-group-addon">Append</span>' . '</div>' ] ); // as widget echo Select2Bootstrap::widget([ 'name' => 'my-name', 'value' => 'my-value', 'clientOptions' => [ 'maximumInputLength' => 20 ] ]);
测试
$ phpunit
使用代码修复工具
我们添加了一个PHP代码修复工具,以标准化我们的代码。它包括Symfony、PSR2和一些贡献者的规则。
./vendor/bin/php-cs-fixer fix ./src --config .php_cs
贡献
有关详细信息,请参阅CONTRIBUTING。
致谢
许可证
BSD许可证(BSD)。请参阅许可证文件以获取更多信息。
定制软件 | 网页和移动开发
www.2amigos.us