xpbl4/yii2-select2-widget

The Select2 widget for Yii framework.

Installs: 38

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:CSS

Type:yii2-extension

v0.1.3 2023-07-15 18:15 UTC

This package is auto-updated.

Last update: 2024-11-28 02:14:35 UTC


README

Latest Version Software License Total Downloads

Select2 widget is a wrapper of Select2 for Yii 2 framework.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist xpbl4/yii2-select2-widget "*"

or add

"xpbl4/yii2-select2-widget": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by:

use xpbl4\select\Select2;

echo $form->field($model, 'field')->widget(Select2::className(), [
    'items' => [
        'item1',
        'item2',
        ...
    ],
    'options' => [
        'multiple' => true,
        'placeholder' => 'Choose item'
    ],
    'pluginOptions' => [
        'width' => '100%',
    ],
    'pluginEvents' => [
        'select2:open' => 'function (e) { log("select2:open", e); }',
        'select2:close' => new JsExpression('function (e) { log("select2:close", e); }')
        ...
    ]
]);

Testing

$ phpunit

Further Information

Please, check the Select2 documentation for further information about its configuration options.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.