Cjuiautocomplete Showing All Results

Good Day!

I need help in trying to figure out why the autocomplete showing all the data via ajax and not filtering it based on the user input. Here is my code.

For the View

<?php

$this->widget(‘zii.widgets.jui.CJuiAutoComplete’, array(

‘name’=>‘clientName’,

‘id’=>‘clientName’,

‘source’=>$this->createUrl(‘updateclient’),

‘options’=>array(

));

?>

for the Controller

public function actionUpdateclient()

{	


	&#036;data_value =array();


	&#036;data_value = array(&quot;red&quot;,&quot;green&quot;,&quot;blue&quot;,&quot;white&quot;,&quot;black&quot;);


	


	echo CJSON::encode(&#036;data_value);

Yii::app()->end();

} 

I want to test it before I use my dynamic model to it. Hope someone could help thanks!

In your Ajax call function, you need get what the user entered.

For example




public function actionUpdateclient()

{

$entered=$_GET['clientName'];//get user entered

$data_value = array("red","green","blue","white","black");



If the user entered "r", then you need return array("red"), so you need create a function how to search "r" in your $data_value array. (try strpos for each array values)

Then return found values only.