Not sure if this is a bug but when I used the AutoComplete widget I found a difference between source and sourceUrl property
I was feeding source with an array let’s say
array("aaa","bbb","ccc")
and all worked well. I was typing "aa" inside text box and I the word "aaa" would appear, in fact only the word "aaa"
On the other hand I would like to use the sourceUrl property, so I created an action inside the appropriate controller and I fed the source url property with an
array("controller/action","param"=>$param)
This action is NOT rendering any view, it just uses the
print json_encode($array);
to produce the results.
Using the second method, when I type "aa" or any other character inside the textbox of the autocomplete widget I get ALL the possible answers, meaning I will see "aaa", "bbb", "ccc"
Of course this is unwanted behaviour
Maybe I have misunderstood something about this widget, not sure. Thank you!
Pligor is right, there is bug, if we use associative array in source attribute of CJuiAutoComplete widget(for example list generated by CHtml::listData(), or any other array whose keys do not belong to range(0,n-1), where n is number of elements).
Acceptable types for Autocomplete source are strings, arrays, and callback functions, and we are providing object here(in case of array whose keys do not belong to range(0,n-1), where n is number of elements in array),
check: zii/widgets/CJuiAutocomplete.php line 90 and helpers/CJavaScript.php line 83.