I have been trying to determine the cause of this issue for 2 days now, but to no avail. Basically I need to obtain a the values for my AutoComplete widget from the database, but it doesn’t display any record at all. However if you pass an array for the source-> array() area, then it displays the autocomplete menus.
$sql ="SELECT locationName FROM locationTypes WHERE locationName LIKE :lName";
$command =Yii::app()->db->createCommand($sql);
$command->bindValue(":lName", '%'.$_GET['term'].'%', PDO::PARAM_STR);
$res =$command->queryColumn();
echo CJSON::encode($res);
Yii::app()->end();
}
The problem is that when I type something into the autocomplete field the browser console displays 403 Forbidden error message. Therefore how should I modify the createUrl method in order to place the actionAutoCompleteTest out of the protected folder?
Did you put the action autocompleteTest in access rules in controller.
public function accessRules()
{
return array(
array('allow',
'actions'=>array('index','view','autocompleteTest'),//adding the autocompleteTest
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}