CJuiAutoComplete with ID [SOLVED]

Hi there,

I have a problem when using the CJuiAutoComplete, specifically in relation to the result in JSON, which brings me ID and NAME.

Controller action JSON code:

$arr = array();

if (isset($_GET['term']))


	$sql = "SELECT Id, Nome FROM Pessoa WHERE Nome LIKE ':Nome%'";

	$command = Yii::app()->db->createCommand($sql);

	$command->bindValue(":Nome", $_GET['term'], PDO::PARAM_STR);

	$models = $command->queryAll();

	foreach ($models as $model)


		$arr[] = array(






echo CJSON::encode($arr);


Controller result:

[{"id":"1","nome":"Fulano da Silva"},{"id":"2","nome":"Fulano de Souza"}]


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









The problem is that when i put the controller to return the ID, CJuiAutoComplete does not work. To load the return JSON, but the list of peoples was to display below the input is not displayed, but when put to the JSON return only the name, it works normally.

Does anyone have any idea how to work with CJuiAutoComplete returning a JSON structure ID and Name?

Thanks in advance to all who collaborate.

Despite not having received no reply, after several attempts, i discovered that the problem was in the controller. In the following code, modified it the variable ‘nome’ by ‘name’:

‘name’ => $model[‘name’],

I leave here the record for anyone to go through that too.

Problem solved!

thanks for the info. and how do you make it work to filter in fact for ID despite you select "name"?