I had requirement of auto complete widget, in which I need to show different value and while posting id of value needed.
And all this need to be part of Active form where I am passing the Model also.
I created a customized widget named "autoCompleteIdValuePair". It has a hidden field , which contains the value which will be posted to the server.
You need to download the widget and copy it to protected/extensions/ folder.
In view, you can define the widget as given below
$this->widget('ext.autoCompleteIdValuePair', array(
'source'=>$this->createUrl("brand/CompanyAutoComplete"),
//'source'=>$model->getCompanyList(''),
'model'=>$model, // leave null in case you don't want Acyive Form field
'attribute'=>'company_name', //Attribute which will be serached by your
'hiddenAttribute'=>'company_id', // The Name of aatribute which will be posted to server
// 'value'=>$model->company_name,
'options'=>array(
//'autoFocus'=>'true',
'minLength'=>'1',
),
));