In my views/site/index page i have used the autocomplete wideget
<?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'autocompleteexample', //every sintax is from http://www.yiiplayground.cubedwater.com/index.php?r=UiModule/jui/ziiAutocomplete
'source'=>$this->createUrl('site/autocompleteTest'),
));
?>
And in the controllers/Sitecontroller i have used
public function ActionAutocompleteTest() {
$res =array();
if (isset($_GET['term'])) {
$qtxt ="SELECT name FROM {{movie}} WHERE name LIKE :name"; // movie is the table name, name is a collum
$command =Yii::app()->db->createCommand($qtxt);
$command->bindValue(":name", '%'.$_GET['term'].'%', PDO::PARAM_STR);
$res =$command->queryColumn();
}
echo CJSON::encode($res);
Yii::app()->end();
}
But i am not getting the expected value as a suggestion.
No suggestion is displayed.
How can i solve this problem?
And if i want to add the Search functionality to another table from getting this value what should be the good approach?
That’s probably because $_GET['term] is not set. It’s on you how to manage to make that work. I think it would work if you pass that param to the URL (?param=whatever).