yii2-multi-select-widget

Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2

Github星跟蹤圖

MultiSelect Widget for Yii2

Latest Stable Version
Total Downloads
Build Status
Latest Unstable Version
Scrutinizer Code Quality

This library contains two of the most useful bootstrap multi-select plugins. One is the MultiSelect Bootstrap plugin from David Stutz and the other is
the MultiSelect.js plugin from Loudev.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require 2amigos/yii2-multi-select-widget "*"

or add

"2amigos/yii2-multi-select-widget" : "*"

to the require section of your application's composer.json file.

Usage for MultiSelect Bootstrap Plugin

Bootstrap multiselect plugin

Using a model

use dosamigos\multiselect\MultiSelect;

<?= $form->field($model, 'attribute')->widget(MultiSelect::className(),[
    'data' => ['super', 'natural'],
]) ?>

Using it as standalone widget

echo MultiSelect::widget([
    'id'=>"multiXX",
    "options" => ['multiple'=>"multiple"], // for the actual multiselect
    'data' => [ 0 => 'super', 2 => 'natural'], // data as array
    'value' => [ 0, 2], // if preselected
    'name' => 'multti', // name for the form
    "clientOptions" => 
        [
            "includeSelectAllOption" => true,
            'numberDisplayed' => 2
        ], 
]);

Usage for MultiSelectListBox Bootstrap Plugin

Bootstrap multiselect plugin

The functionality to use this plugin is actually the same as its an extension of the previous one. The only thing that
changes its use is its set of configuration options.

use dosamigos\multiselect\MultiSelectListBox;
use yii\web\JsExpression;

<?= $form->field($model, 'attribute')->widget(MultiSelectListBox::className(),[
    'data' => ['super', 'natural'],
    'clientOptions' => [
        'selectableHeader' => "<input type='text' class='search-input' autocomplete='off' placeholder='try \"12\"'>",
        // yep, events MUST use JsExpression
        'afterInit' => new JsExpression('function(ms){ // ... }')
    ]
]) ?>

Further Information

I highly recommend you to visit both sites:

Then, check what are the options that would allow you to create one or the other. I have never used both on the same
UI and I am not sure whether they can be used together or not. The MultiSelectListBox has a different constructor
function name but very similar (multiSelect vs multiselect), but we are not sure whether they are compatible or not.

If you have the experience and willing to share, let us know on the issues and we will update this README file
accordingly.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

2amigOS!
Web development has never been so fun!
www.2amigos.us

主要指標

概覽
名稱與所有者2amigos/yii2-multi-select-widget
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證Other
所有者活动
創建於2014-01-09 00:19:40
推送於2021-05-08 08:13:05
最后一次提交2019-02-15 20:44:53
發布數3
最新版本名稱1.0.0 (發布於 2017-12-10 13:37:50)
第一版名稱0.1.0 (發布於 2014-04-20 12:56:19)
用户参与
星數45
關注者數19
派生數30
提交數40
已啟用問題?
問題數19
打開的問題數8
拉請求數4
打開的拉請求數2
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?