Yii2实现搜索下拉

发表于

 <?= $form->field($model, 'member_id')->widget(\kartik\select2\Select2::classname(), [
                'data'=>$member,
                'options' => ['multiple'=>false, 'placeholder' => '搜索用户账号', 'value' => $model->member_id],
                'pluginOptions' => [
                    'allowClear' => true,
                    'minimumInputLength' => 2,
                    'language' => [
                        'errorLoading' => new JsExpression("function () { return '查询中...'; }"),
                    ],
//                    'ajax' => [
//                        'url' => $url,
//                        'dataType' => 'json',
//                        'data' => new JsExpression('function(params) { return {q:params.term}; }')
//                    ],
                    'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                    'templateResult' => new JsExpression('function(goods) { return goods.text; }'),
                    'templateSelection' => new JsExpression('function (goods) { return goods.text; }'),
                ],
            ])->label("用户账号"); ?>

 

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注