This widget inputs text and gives search result via drop down list. Question is how can I customize it? Is there any kind of form or some property where I could write some html template to get answers as stylish hyperlinks with images and etc. ?
This code is not working unfortunately.
This is view inside layout
echo NavX::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'encodeLabels' => false, //вот эта строка
'items' =>
[
['label' => Typeahead::widget([
'name' => 'country_1',
'options' => ['placeholder' => 'Filter as you type ...'],
'scrollable' => true,
'pluginOptions' => ['highlight'=>true],
'dataset' => [
[
'prefetch' => Url::to(['site/search']),
'limit' => 10
]
]
])],
['label' => 'About', 'url' => ['/site/about']],
]
]);
NavBar::end();
and controller
public function actionSearch()
{
// var_dump('TTTTTT'); die;
$searchModel = ProductName::find()->asArray()->all();;
// echo $searchModel;
return \yii\helpers\Json::encode($searchModel);
// echo 'test';
}
I've tried different this also not working
public function actionSearch()
{
foreach (ProductName::find()->each() as $search_products) {
$search_products_array[$search_products->nameID] = $search_products->name;
}
return \yii\helpers\Json::encode( $search_products_array);
}
As u can see I've tried different options in controller, cause search was not responding to key inputs. But controller is ok, because if I manually go to its url it responds well.