项目作者: 2amigos

项目描述 :
Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
高级语言: PHP
项目地址: git://github.com/2amigos/yii2-multi-select-widget.git
创建时间: 2014-01-09T00:19:40Z
项目社区:https://github.com/2amigos/yii2-multi-select-widget

开源协议:BSD 3-Clause "New" or "Revised" License

下载


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

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

or add

  1. "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

  1. use dosamigos\multiselect\MultiSelect;
  2. <?= $form->field($model, 'attribute')->widget(MultiSelect::className(),[
  3. 'data' => ['super', 'natural'],
  4. ]) ?>

Using it as standalone widget

  1. echo MultiSelect::widget([
  2. 'id'=>"multiXX",
  3. "options" => ['multiple'=>"multiple"], // for the actual multiselect
  4. 'data' => [ 0 => 'super', 2 => 'natural'], // data as array
  5. 'value' => [ 0, 2], // if preselected
  6. 'name' => 'multti', // name for the form
  7. "clientOptions" =>
  8. [
  9. "includeSelectAllOption" => true,
  10. 'numberDisplayed' => 2
  11. ],
  12. ]);

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.

  1. use dosamigos\multiselect\MultiSelectListBox;
  2. use yii\web\JsExpression;
  3. <?= $form->field($model, 'attribute')->widget(MultiSelectListBox::className(),[
  4. 'data' => ['super', 'natural'],
  5. 'clientOptions' => [
  6. 'selectableHeader' => "<input type='text' class='search-input' autocomplete='off' placeholder='try \"12\"'>",
  7. // yep, events MUST use JsExpression
  8. 'afterInit' => new JsExpression('function(ms){ // ... }')
  9. ]
  10. ]) ?>

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