Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yii-cms/yii2-select2

Select2 widget for Yii2 framework.
https://github.com/yii-cms/yii2-select2

Last synced: 26 days ago
JSON representation

Select2 widget for Yii2 framework.

Awesome Lists containing this project

README

        

Select2 widget for Yii2 framework.
==================================

https://github.com/select2/select2

```php
= $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.");
}',
],
]) ?>
```

```php
= Select2::widget([
'name' => 'InputName',
'items' => ArrayHelper::map(User::find()->all(), 'id', function($model) {
return $model->fio . " <{$model->email}>";
}),
'clientOptions' => [
'placeholder' => 'User',
'allowClear' => true,
]
]) ?>
```