Answer the question
In order to leave comments, you need to log in
How to show label instead of value in Jquery UI Autocomplete?
I pass the id=>value array to the widget.
When the list is open, I see the value options, but when I select one of the elements, I see not the value, but the id.
That is, I enter "mos" and
see the list:
moskovia
moscow
mosfilm I select
"Moscow"
in the input "4" this is the id for "Moscow". when submitting the form, 4 is passed and the user sees on the page in the input "4" , but should see "Moscow".
Wonders.
<?php
echo AutoComplete::widget([
'name' => 'Board[idinbd]',
'options'=>['id'=>'board-idinbd', 'placeholder' => 'Начните вводить модель...', 'class'=>'form-control'],
'clientOptions' => [
'minLength' => '3',
'delay' => '200',
],
]);
$this->registerJs("
$('#board-idinbd').autocomplete({
source: function( request, response ) {
var brandmodels = request.term;
$.ajax({
url: 'ajaxbrandmodels',
dataType: 'json',
'type': 'get',
data: {bm:brandmodels},
success: function( data ) {
response( data );
}
});
}
});
");
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question