Please help me!
I have problem with search in autocomplete.
tbl_port(id,name,port_code,port_type)
in autocomplete I want to search both name and port_code. But I don’t know how to do it!
this is my controller
public function actionPort() {
$criteria = new CDbCriteria;
$criteria->select = array('id', 'name','port_code');
$criteria->addSearchCondition('name', strtoupper( $_GET['term']) ) ;
$criteria->limit = 15;
$data = Port::model()->findAll($criteria);
$arr = array();
foreach ($data as $item) {
$arr[] = array(
'id' => $item->id,
'value' => $item->name." (".$item->port_code.")",
'label' => $item->name." (".$item->port_code.")",
);
}
echo CJSON::encode($arr);
}
thank!