Answer the question
In order to leave comments, you need to log in
How to make a drop down list of cities in yii2?
Hello. there is a table of cities. How to implement input with a datalist - so that when you enter a value in the field, the city is displayed in the list
I did this - but options do not work like that
Convert the city object to an array
$items = ArrayHelper::map($cities,'id','name');
<?= $form->field($search, 'fullname', ['options'=>['list'=>'datalist1']]); ?>
<datalist id="datalist1">
<?php foreach($items as $city): ?>
<option value="<?php echo $city?>">
<?php endforeach; ?>
</datalist>
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