T
T
Tatiana Komarova2015-08-31 16:54:21
JavaScript
Tatiana Komarova, 2015-08-31 16:54:21

Why does the AutoComplete widget return the entire list of options?

The AutoComplete widget used in the GridView filter, when an external source is connected, returns the complete list of options, regardless of what the user enters.
If you directly specify an array in source, it works correctly. What could be wrong?
Widget connection:

'filter' => AutoComplete::widget([
                    'model' => $searchModel,
                    'attribute' => 'City',
                    'clientOptions' => [
                        'source' => Url::toRoute('columnautocomplete'),
                        
                    ],
                    'options' => ['class' => 'form-control'],
                ]),

Action in controller:
public function actionColumnautocomplete() {
        return Json::encode(Phones::find()
            ->select(['City as label'])->distinct()
            ->asArray()
            ->all());
    }

Result:
06d71bfa993f4f95b8a388f7257ef210.jpg
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2015-08-31
@tatia_kom

And what do you think it should produce if you do not impose any restrictions when selecting options on the server?

V
Vlad Pasechnik, 2015-08-31
@jumper423

Add a condition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question