Yii Autocomplete Widget From Database

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.

$this->widget(‘zii.widgets.jui.CJuiAutoComplete’, array(

'name'=>'addressCity',


'value'=>'k',


'model'=>$model,


'source'=> $this->createUrl('hospital/autocompleteTest'),

));

$res =array();

if (isset($_GET[‘term’])) {

$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?

My question is how do I reference the JQuery.js file from inside the protected folder and not from the assets folder

Dear Yoosuf

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('*'),

			),

		);

	}




Kindly check that.

Regards.

Yes I did include it there, but I have used the full name actionAutoCompleteTest rather than the name autoCompleteText

Thanks a lot

I fixed my problem, thanks guys :)