kartik-v / yii2-widgets

Collection of useful widgets for Yii Framework 2.0
http://demos.krajee.com/widgets
Other
558 stars 175 forks source link

I can't render my field with model value. #323

Open hoyo0210 opened 8 years ago

hoyo0210 commented 8 years ago

How do i render my field with model value. My code is below:

echo $form->field($model, 'position')->widget(\kartik\widgets\Typeahead::className(), [
        'options' => ['placeholder' => 'placeholder...'],
        'data' => [$model->position],
        'pluginOptions' => ['highlight'=>true],
        'dataset' => [
            [
                'limit' => 10,
                'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('value')",
                'display' => 'value',
                'prefetch' => \yii\helpers\Url::to(['/site/area']),
                'remote' => [
                'url' => \yii\helpers\Url::to(['site/area']) . '?q=%QUERY',
                'wildcard' => '%QUERY'
            ]
        ]
    ]
])

Did I miss something?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/59858393-i-can-t-render-my-field-with-model-value?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github).