Editable Dropdown Using HTML Input List and DataList

I want to create an Editable Dropdown in Yii using the HTML Input List Attribute.

I notice the Yii ActiveField does not provide an option for Input List. Any suggestions on how to implement this?

This turned out to be rather simple. Here is the solution:

use yii\bootstrap4\ActiveForm;
<?= $form->field($model, 'majorcity')->textInput(['list' => 'datalistOptions']) ?>
<datalist id="datalistOptions">
  <option value="San Francisco">
  <option value="New York">
  <option value="Seattle">
  <option value="Los Angeles">
  <option value="Chicago">
1 Like

You can also just use input instead of textInput. Optionall add additional classes or placeholder text as below:

<?= $form->field($model, 'majorcity')->input(Null, ['class' => 'form-control w-50', 'list' => 'datalistOptions', 'placeholder'=>'']) ?>

Using text is probably better I think.