CJuiAutoComplete , attribute and value

i have a autocomplete field with:

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




            'value'=>'a default value',





but default value don’t appear in autocomplete filed.

if i remove attribute and use name instead of , value appear in autocomplete.

how can i have attribute and value together?

If you look at the line 83 of CJuiAutocomplete you find the response to your question


	echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);


	echo CHtml::textField($name,$this->value,$this->htmlOptions);

That means that has priority on the model attribute…

If you wish to have a default value when the attribute is empty then use something like this:

$config = !empty($model->title)? array('model'=>$model, 'attribute'=>'title') : array('value'=>'a default value');

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




             )), $config)


// totally untested

thank u but i want attribute and a default value together but it seems this is impossible.

i’m right?

Just initialize the attribute with the default value.