Controller:
$products = ArrayHelper::map(Products::find()->all(), ‘id’, ‘name’);
I have taken my products list as array using the above code which outputs
Array
(
[1] => shirt
[2] => pant
[3] => t-shirt
[4] => sample
)
and in my view i have passed the array to Jui Autocomplete widget as
<?= AutoComplete::widget([
'model' => $products,
'attribute' => 'products',
'clientOptions' => [
'source' => $products,
],
]); ?>
which it results in jquery as
jQuery(’#w1’).autocomplete({“source”:[{“1”:“shirt”,“2”:“pant”,“3”:“t-shirt”,“4”:“sample”}]});
but my autocomplete doesn’t populates the result.
What I’m lacking in please advise. Thanks in advance.