/**
* @param string $term The string to match (automatically sent by the cjuiautocomplete widget)
* @param int $limit
*/
public function actionAutocomplete( $term, $limit = 50 )
{
// build the query criteria
$countryCriteria = new CDbCriteria();
$countryCriteria->condition = "name LIKE '$term%'";
$countryCriteria->order = "name ASC";
$countryCriteria->limit = $limit;
// get the possible options
$countries = Country::model()->findAll( $countryCriteria );
foreach( $countries as $country )
{
$returnVal[] = array('label'=>$country->name,'id'=>$country->id);
}
// output as json for the autocomplete to render
echo CJSON::encode($returnVal);
}
I don´t know what is the problem, but its happend all ok. but the AutoComplete don´t work.
As you state your controller is called CountriesController the ID of it resolves to ‘countries’ and your Action actionAutocomplete resolves to ‘autocomplete’.