CJuiAutoComplete issue- Clear hidden field

Hi,

I’m developing a personal website to learn more about Yii framework.

I’ve added the CJUIAutocomplete-Widget which works fine.

The CJuiAutoComplete-Widget lists the found cities from my database together with the ID when the user enters the letters of the city in a text field.

The ID is stored in a hidden field if the user clicks on the suggested list from the CJUIAutocomplete result.

And the city is displayed in the text field.

But when the user deletes the city from the text field, then the ID will not be deleted from the hidden field.

How can I accomplish that?

What can I do so that the ID is deleted if the text field is being emptied again?

Kind regards

Hi there,

I have the exact same setup and problem as you do, and I never did get around to entirely fixing it. I did, however, add an onclick action so that the selected name and hidden id is cleared when the user clicks into the input box.


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

...

	'htmlOptions'=>array(

		'onclick'=>'javascript:$("#CountrySelect").val("");$("#' . CHtml::activeId($model,'CountryId') . '").val("");',

	),

...

));

I imagine you could also do an "onblur" listener for when the user focuses out of the input box, and have it clear out the hidden id on an invalid input.