Hi,
I have a question, I am wondering if it is possible to fill in options of a drop down box using CHtml::tag . ? Normally with autocomplete you call an URL which will be handled off in the controller as per example below: The jquery will fetch the json data and fill the select options.
It is possible to use instead of json to use chtml:tag ? if so, how would i be able to do so?
echo CHtml::tag('select',
array('id' => 'names', 'value'=>$value),CHtml::encode($name),true);
controller code:
public function actionAutocompleteTest2() {
$res =array();
if (isset($_GET['term'])) {
$criteria = new CDbCriteria();
$criteria->condition = 'location LIKE :searchterm';
$criteria->params = array(':searchterm'=>'%'. $_GET['term'] . '%');
$res2 = Photos::model()->findAll($criteria);
//$res = CHtml::listDate($res2);
$res = CHtml::listData($res2, 'id', 'location');
//Kint::dump($res);
echo CJSON::encode($res);
Yii::app()->end();
}