kak / select2
select2 widgets for Yii2
Installs: 3 027
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Language:CSS
Requires
- bower-asset/select2: ^4.0
- bower-asset/slimscroll: *
- yiisoft/yii2: *
Requires (Dev)
- codeception/codeception: >=4.1.22
- codeception/module-asserts: >=1.3
- codeception/module-yii2: >=1.1
- symfony/event-dispatcher-contracts: >=2.2.0
README
Select2 widgets for Yii2
Preview
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist kak/select2 "dev-master"
or add
"kak/select2": "dev-master"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
<?= \kak\widgets\select2\Select2::widget([ 'toggleEnable' => false, // visible select all/unselect all 'selectLabel' => 'select all', 'unselectLabel' => 'unselect all', 'options' => [ 'data-scroll-height' => 150, // auto scroll 'data-item-width' => 100, // 100|auto ] 'multiple' => true, 'value' => ['val1','val2'], 'name' => 'inputName', 'items' => [ 'val1' => 'options1', 'val2' => 'options2', 'val3' => 'options3', 'val4' => 'options4', ], ]); ?>
<?= $form->field($model, 'list')->widget('\kak\widgets\select2\Select2', [ 'items' => [ 'val1' => 'options1', 'val2' => 'options2', 'val3' => 'options3', 'val4' => 'options4', ], 'options' => [ 'class' => 'myCssClass' ], 'clientOptions' => [], // js options select2 ]) ?>