dropDownList options from database

hi.

I use dropDownList field in ActiveForm, and get its options

from db:




    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'color')->dropDownList(ArrayHelper::map(Color::find()->all(),'name','name') ) ?>



But what I need, is to get from db only part of options,

based on the prefix written manually in this field.

Which widget has this feature ?

Hi,

i think you mean to add where to find function:


Color::find()->where(['field' => $value])->all()

I don’t know if that what you mean or no.

I want to search with prefix :


Color::find()->where(['like', ['field' => "$value%"])->all()

But the $value is in form not sent yet.

Maybe it is possible to add ajax code to send $value,

or other widget has this feature?

I found that the jui\AutoComplete widget has this functionality.

Solved.