0

i have table that have developer_id, name, family .etc columns i want to show suggest name in input in view i did something like this but this give me a input whitout any suggestion and autocompelte why?

$data = Developers::find()
    ->select(['name as value', 'name as  label','developer_id as id'])
    ->asArray()
    ->all();

    echo AutoComplete::widget([
        'name' => 'dname',
        'id' => 'ddd',
        'clientOptions' => [
            'source' => $data,
            'autoFill'=>true,
            'minLength'=>'1',
            'select' => new JsExpression("function( event, ui ) {
            $('#aa').val(ui.item.id);
        }")],
    ]);
     ?>
<input id="aa"  value="" type="hidden">
moh
  • 433
  • 10
  • 33

1 Answers1

0

I copied and pasted your code in one of my views. I just changed your model so I am using one of my models (tables). Your code works perfectly in my view. So I think you should check if the problem is one of these:

  1. You are not correctly importing one of these:

    use backend\models\Developers;

    use yii\jui\AutoComplete;

    use yii\web\JsExpression;

  2. Your table Developers is empty

  3. In the part of your code that says:

    ->select(['name as value', 'name as label','developer_id as id'])

    Are you sure your table developer has the columns name and developer_id?

ManuelCash
  • 153
  • 10
  • use app\models\Developers; use yii\helpers\Html; use yii\helpers\Url; use yii\jui\AutoComplete; use yii\web\JsExpression; use yii\web\View; are imported well and if i print_r() $data i can see values as well .... its really Weird – moh Sep 04 '17 at 16:33