yii-cms / yii2-select2
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
Requires
- bower-asset/select2: 4.0.12
- yiisoft/yii2: >=2.0
This package is auto-updated.
Last update: 2024-10-28 18:08:01 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, ] ]) ?>