Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xutl/yii2-select2-widget
https://github.com/xutl/yii2-select2-widget
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/xutl/yii2-select2-widget
- Owner: xutl
- Created: 2016-10-24T06:15:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-27T03:40:11.000Z (about 7 years ago)
- Last Synced: 2024-10-13T15:23:11.940Z (about 1 month ago)
- Language: JavaScript
- Size: 114 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii2-select2-widget
````
= $form->field($model, 'category_id')->widget(Select2::className(), [
'items' => ArrayHelper::map(\common\models\Category::find()->where(['parent' => null])->asArray()->all(), 'id', 'name'),
'clientOptions' => [
'placeholder' => Yii::t('app', 'please choose'),
],
]) ?>= $form->field($model, 'tagValues')->widget(Select2::className(), [
'options' => [
'multiple' => true
],
'items' => ArrayHelper::map($model->tags, 'id', 'name'),
'clientOptions' => [
'placeholder' => Yii::t('app', 'Add the tag you are looking for'),
'tags' => true,
'ajax' => [
'url' => Url::to(['/user/settings/auto-complete']),
'dataType' => 'json',
//延迟250ms发送请求
'delay' => 250,
'cache' => true,
'data' => new \yii\web\JsExpression('function (params) {
return {
query: params.term
};
}'),
'processResults' => new \yii\web\JsExpression('function (data) {
return {
results: data
};
}'),
],
],
]) ?>
````