i am trying to get the selected value, into the hidden field. But i don't know where to put the javascript or which function to use.
$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
'name'=>'stands',
'source'=>$teststands,
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
),
'htmlOptions'=>array(
'style'=>'height:20px;',
'class'=>'form-control',
),
));
echo CHtml::hiddenfield('output', '');
thanks in advance.
Try this (note, I haven't tested it, but I have something similar in my Yii app):
$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
'name'=>'stands',
'source'=>$teststands,
'htmlOptions'=>array(
'style'=>'height:20px;',
'class'=>'form-control',
),
'options'=>array(
'minLength'=>'2',
'select'=>'js:function( event, ui ) {
$("#hidden-field").val(ui.item.value);
return true;
}',
),
));
echo CHtml::hiddenfield('output', '', array('id'=>'hidden-field');
You may also want to have a look at this forum thread on Yii: http://www.yiiframework.com/forum/index.php/topic/10586-cjuiautocomplete-howto/