Renders a MultiSelect Bootstrap plugin widget.
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.
Using a model:
use dosamigos\multiselect\MultiSelect;
<?= MultiSelect::widget([
'data' => ['super', 'natural'],
'name' => 'Test'
]) ?>
Multiselect Option:
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
],
]);
Note: You can make use of 'model'
and 'attribute'
for its configuration too instead of 'name'
and 'value'
.
Web development has never been so fun! www.2amigos.us