PHP code example of softark / yii2-dual-listbox
1. Go to this page and download the library: Download softark/yii2-dual-listbox library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
softark / yii2-dual-listbox example snippets
" "php": ">=7.0.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"istvan-ujjmeszaros/bootstrap-duallistbox": "~3.0.0",
"softark/yii2-dual-listbox": "dev-master"
},
" "php": ">=7.0.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap4": "*", // OR
"yiisoft/yii2-bootstrap5": "*",
"istvan-ujjmeszaros/bootstrap-duallistbox": "~4.0.0",
"softark/yii2-dual-listbox": "dev-master"
},
use softark\duallistbox\DualListbox;
...
$options = [
'multiple' => true,
'size' => 20,
];
// echo Html::listBox($name, $selection, $items, $options);
echo DualListbox::widget([
'name' => $name,
'selection' => $selection,
'items' => $items,
'options' => $options,
'clientOptions' => [
'moveOnSelect' => false,
'selectedListLabel' => 'Selected Items',
'nonSelectedListLabel' => 'Available Items',
],
]);
use softark\duallistbox\DualListbox;
...
$options = [
'multiple' => true,
'size' => 20,
];
// echo Html::activeListBox($model, $attribute, $items, $options);
echo DualListbox::widget([
'model' => $model,
'attribute' => $attribute,
'items' => $items,
'options' => $options,
'clientOptions' => [
'moveOnSelect' => false,
'selectedListLabel' => 'Selected Items',
'nonSelectedListLabel' => 'Available Items',
],
]);
use softark\duallistbox\DualListbox;
...
$options = [
'multiple' => true,
'size' => 20,
];
// echo $form->field($model, $attribute)->listBox($items, $options);
echo $form->field($model, $attribute)->widget(DualListbox::className(),[
'items' => $items,
'options' => $options,
'clientOptions' => [
'moveOnSelect' => false,
'selectedListLabel' => 'Selected Items',
'nonSelectedListLabel' => 'Available Items',
],
]);