Hi,
I have a search field which uses the typeahead-widget from kartik. I am wondering now, how to access different values from a search-item than the display name. This is my search-field:
// $data = array with ID => DisplayName
Typeahead::widget([
'name' => 'header-search',
'options' => ['placeholder' => 'My test search field'],
'pluginOptions' => ['highlight' => true],
'dataset' => [
[
'local' => $data,
'limit' => 10
]
],
'pluginEvents' => [
'typeahead:selected' => 'function() {window.open("' . LinkHelper::getHomeUrl() . '" + $(this).typeahead("val"),"_self")}',
'typeahead:autocompleted' => 'function() {window.open("' . LinkHelper::getHomeUrl() . '" + $(this).typeahead("val"),"_self")}'
]
]);
The question is, how can I access the ID-field of a search-item so that I can use the ID to generate the URL where to go when selecting an item.
Can you implement something like a custom adapter?
Does anybody know how to do this?
Thank you very much!