2amigos/yii2-select2-widget

此软件包已被废弃,不再维护。没有推荐替代软件包。

具有Bootstrap主题能力的Yii2 Select 2 jQuery插件

安装数量: 156 851

依赖: 0

推荐者: 0

安全: 0

星标: 7

关注者: 4

分支: 7

开放问题: 1

类型:yii2-extension

0.1.2 2017-07-26 15:34 UTC

This package is auto-updated.

Last update: 2023-08-16 03:13:12 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Select2提供具有搜索、标签、远程数据集、无限滚动和许多其他常用选项的自定义选择框。

安装

通过Composer

$ composer require 2amigos/yii2-select2-widget

使用方法

小部件有两种风格,一种是经典风格,一种是Bootstrap风格。除了Bootstrap风格需要一些调整外,小部件的配置主要通过clientOptionsclientEvents完成。这些属性分别用于保存插件的配置和其事件。

因此,我们强烈建议您访问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)。请参阅许可证文件以获取更多信息。

687474703a2f2f7777772e67726176617461722e636f6d2f6176617461722f35353336333339346437323934356666376564333132353536656330343165302e706e67
定制软件 | 网页和移动开发
www.2amigos.us