Hi
I’m using the CJuiAutoComplete in my site. As an example I have this code in my controller:
public function actionNames()
{
$res=array(array('id' => 1, 'name' => 'Sam and Max'), array('id'=>2, 'name'=>"Full Throttle"));
echo CJSON::encode($res);
Yii::app()->end();
}
And in my view I’ve got:
<?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'game',
'sourceUrl'=>array('/game/names'),
'options'=>array(
'minLength'=>'2',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
)); ?>
As you can see, the actionNames returns a array of arrays. The reason for this is I want to use ‘name’ to fill the auto complete list, and then ‘id’ to use with actionView($id) when I submit the search form. How can I accomplish this?
Write text in field (for example ‘sam’) -> actionNames returns array(‘id’ => 1, ‘name’ => ‘Sam and Max’) -> (from this point i need help) autocomplete field is filled with var[‘name’] -> form submit redirects to page/view/var[‘id’]