How can one implement a jQuery autocomplete (autosuggest) text input with images on the side of the text?
I have the basic autocomplete working.
In the view:
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'search-main',
'sourceUrl'=>$this->createUrl('site/autocomplete'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
'delay'=>'200',
),
'htmlOptions'=>array(
'style'=>'height:30px;'
),
));
In the controller:
public function actionAutoComplete() {
$res = array();
if (isset($_GET['term'])) {
$qtxt = "SELECT businessName FROM business WHERE businessName LIKE :businessName LIMIT 5";
$command = Yii::app()->db->createCommand($qtxt);
$command->bindValue(":businessName", '%'.$_GET['term'].'%', PDO::PARAM_STR);
$res = $command->queryColumn();
}
echo CJSON::encode($res);
Yii::app()->end();
}
I’m new to yii. Any help is appreciated!