Search id by text and foreign key

Hi.

I have form:


<?= $form->field($model, 'id')->textInput() ?>


<?= $form->field($model, 'occurrence')->textInput() ?>


<?= $form->field($model, 'probability')->textInput(['maxlength' => true]) ?>

First input is a foreign key where table have names.

I don’t know how to do If I type “aaa” get id foreign key.

Normally I use array helper and dropDownlist, but I can’t here because first table have 400000 record.

I don’t know how to do?

How to search in input form and return id in this input

I usually use a popup window for this kind of situation.

  1. In that popup, you can see a gridview of the items, with search and soft functionality. And when you have selected an item, it will fill the id of the item to the target field.

  2. Another solution may be jQuery UI autocomplete. It could be a little smarter.

Unfortunately both the solutions require some experience and skill. And I can not explain them in details for your current scenario.

  1. Link your input form from the index list or view page of that foreign model, then you can assign the id beforehand.