consultnn / yii2-select2
Yii2 小部件包装器,用于 jQuery select2 插件 v4.*
v1.0.1
2015-08-24 14:15 UTC
Requires
- php: >=5.4.0
- bower-asset/select2: 4.*
- yiisoft/yii2: 2.0.*
This package is not auto-updated.
Last update: 2024-09-14 17:48:12 UTC
README
Select2 小部件是 Yii 2 框架对 Select2 的包装器。
安装
php composer.phar require --prefer-dist consultnn/yii2-select2 "*"
或在 composer.json
中添加
"consultnn/yii2-select2": "*"
使用方法
echo $form->field($model, 'attribute')->widget(
\consultnn\select2\Select2::className(),
[
'options' => [
'multiple' => true
],
'items' => $items, // @see Html::dropDownList() $items argument
'pluginOptions' => [
'ajax' => [
'url' => Url::toRoute(['controller/autoComplete']), // return Json::encode(['results' => [['id' => 1, 'text' => 'text1'], ...]]);
'dataType' => 'json'
]
]
]
);