Answer the question
In order to leave comments, you need to log in
Yii2 AutoCompleate dubbing text input?
Hi all.
There is a search form, the first and second input I use the widget from the kartik \typeahead\Typeahead;. When I try to find a tow truck, I get dubbed, I would like to get rid of it.
An example of how it looks like:
This is a table where users save their specialty
alt="image"/>
controller
public function actionCategoryList($q = null)
{
$query = new Query();
$query->select('title')
->from('profile_has_category')
->where('title LIKE "%' . $q . '%"')
->orderBy('title');
$command = $query->createCommand();
$data = $command->queryAll();
$out = [];
foreach ($data as $d) {
$out[] = ['value' => $d['title']];
}
echo Json::encode($out);
}
Typeahead::widget([
'name' => 'Search[category]',
'options' => ['placeholder' => 'Искать специальности ...'],
'pluginOptions' => ['highlight' => true],
'class' => 'search-input-spec',
'dataset' => [
[
'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('value')",
'display' => 'value',
//'prefetch' => $asset->baseUrl . '/samples/countries.json',
'remote' => [
'url' => Url::to(['search/category-list']) . '?q=%QUERY',
'wildcard' => '%QUERY'
]
]
]
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question