yii-cms/yii2-select2 Select2 widget for Yii2 framework.

select2

Select2 widget for Yii2 framework.

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

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v0.5 is the latest of 4 releases



Unknown license
Stats
5 github stars & 3 github forks
2 downloads in the last day
2 downloads in the last 30 days
18426 total downloads