CAutocomplete - Choose an other value then selected

Hi,

I’m using CAutocomplete. If the user is selecting a value, then an other value should be selected.

Example: If somebody is typing "BM", then following is showing in my Autocomplete field

Auto > Marke > BMW

If the user select now this result, then it should only "BMW be selected"

http://www.yiiframework.com/wiki/25/ doenst help

Here is my code




<?php echo CHtml::beginForm(array('engine/search'), 'get', array('name' => 'frm', 'autocomplete' => 'off'));?>


<?php $this->widget('CAutoComplete',

         array

         (

		'name'			=>	's',

          	'value'			=>	$sWert,


		'url'			=>	array('translation/autoCompleteLookup'),

          	'extraParams'	=>	array('l' => 'js:function(){ return $("#carType").val();}'), 


		'minChars'		=>	2, 

		'delay'			=>	10,


          	'matchCase'		=>	false, //match case when performing a lookup?

 		'htmlOptions'	=>	array('size'=>'40'),

          	'formatItem'	=>	"function(result, i, num, term){return result[0] + '' + result[1];}",

 		'methodChain'	=>	".result(function(event,item){\$(\"#phrase\").val(item[1]).parents(form).submit()	;})",

             ));

?>

<?php echo CHtml::hiddenField('phrase'); ?>



Mein AutoComplete




public function actionAutoCompleteLookup()

{

	//Yii::app()->request->isAjaxRequest && 

		

	if(isset($_GET['q']))

	{

		$sSearchphrase	= $_GET['q'];

		$iLimit			= min($_GET['limit'], 50);


		$oCriteria = new CDbCriteria;

		$oCriteria->condition = "phrase_clear LIKE :phrase";

		$oCriteria->params = array(":phrase" => "$sSearchphrase%");

		$oCriteria->limit = 10;


		$userArray = Engines::model()->findAll($oCriteria);


		$returnVal = '';

		foreach($userArray as $userAccount)

		{

			$returnVal .= $userAccount->getAttribute('language') . "|" . $userAccount->getAttribute('phrase')."\n";

		}

		echo $returnVal;

	}

}



I now that the function is deprecated, but its working fine for my website

thx!