Search code examples
phpyii2active-formtypehead

Typeahead Widget - © Kartik How return id


I'm use Typeahead by Kartik.

<?= $form->field($model, 'id_operation')->widget(Typeahead::className(), [
    'pluginOptions' => ['highlight'=>true],
    'dataset' => [
        [
            'local' => \app\models\Operation::find()->asArray()->all(),
            'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')",
            'display' => 'name',
        ]
    ]
]) ?>

Need return value id . But select autocomplete by column name. Help, please


Solution

  • Read here about a solution, it's not possible directly and you should probably change to select2 with specific configuration to achieve your goal. https://github.com/kartik-v/yii2-widgets/issues/202