kak/select2

select2 widgets for Yii2

Installs: 2 710

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 0

Open Issues: 0

Language:CSS

1.0.1 2023-07-04 17:19 UTC

This package is auto-updated.

Last update: 2024-04-04 19:08:53 UTC


README

Select2 widgets for Yii2

Preview

68747470733a2f2f6c68332e676f6f676c6575736572636f6e74656e742e636f6d2f2d535974794b7866765a7a342f5662437745507a767845492f41414141414141414143342f4f723563314f624b37454d2f733333392d496334322f73656c65637432507265766965772e706e67

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
]) ?>