Where is the Yii2 autocomplete class?

I used:

echo AutoComplete::widget([
    'name' => 'file',
        'clientOptions' => [
        'source' => ['USA', 'RUS'],
    ],
]);

      

But I am getting error:

Class 'AutoComplete' not found.

      

+3


source to share


1 answer


You must first install the Yii 2 JQuer UI extension . Fully qualified class name with the yii \ jui \ Autocomplete namespace . You can use it like this:

use yii\jui\Autocomplete;

...

echo AutoComplete::widget([
    'name' => 'file',
    'clientOptions' => [
        'source' => ['USA', 'RUS'],
    ],
]);

      



or

echo yii\jui\AutoComplete::widget([
    'name' => 'file',
    'clientOptions' => [
        'source' => ['USA', 'RUS'],
    ],
]);

      

+5


source







All Articles