yii-cms/yii2-select2

There is no license information available for the latest version (v0.5) of this package.

Select2 widget for Yii2 framework.

Installs: 18 426

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 3

Open Issues: 0

Type:yii2-extension

v0.5 2020-01-28 08:23 UTC

This package is auto-updated.

Last update: 2024-04-28 17:11:06 UTC


README

https://github.com/select2/select2

    <?= $form->field($model, 'user_id')->widget(Select2::className(), [
        'items' => ArrayHelper::map(User::find()->all(), 'id', function($model) {
            return $model->username . " <{$model->email}>";
        }),
        'clientOptions' => [
            'placeholder' => 'User',
            'allowClear' => true,
        ],
        'clientEvents' => [
            'change'=>'function (e) {
                console.log("Select2 change.");
            }',
        ],
    ]) ?>
    <?= Select2::widget([
        'name' => 'InputName',
        'items' => ArrayHelper::map(User::find()->all(), 'id', function($model) {
            return $model->fio . " <{$model->email}>";
        }),
        'clientOptions' => [
            'placeholder' => 'User',
            'allowClear' => true,
        ]
    ]) ?>