I am working on autocomplete widgets. This is my code so far.
My opinion:
<?php $data = Company::find() ->select(['name as value', 'name as label','c_id as id']) ->asArray() ->all(); echo AutoComplete::widget([ 'name' => 'Company', 'id' => 'ddd', 'clientOptions' => [ 'source' => $data, 'autoFill'=>true, 'minLength'=>'4', 'select' => new JsExpression("function( event, ui ) { console.log(ui); $('#user-company').val(ui.item.id); }")], ]); ?> <?= Html::activeHiddenInput($model, 'company')?>
If you select the option, the autocomplete parameters are updated in the text field, but the hidden field is not updated.
How can I get a hidden field to update when I select an option?
php yii2
Dency GB
source share