anmaslov/yii2-autocomplete-widget

Yii2 的 Ajax 自动完成小部件

v1.1 2015-06-29 20:56 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:31:44 UTC


README

Yii2 Latest Version Build Status Software License

自动完成扩展是 Yii2 对 jQuery 自动完成插件 的包装小部件。自动完成允许您轻松地为文本输入字段创建自动完成/自动建议框。

除了 jQuery 之外没有其他依赖项。该小部件特别为 Bootstrap 3 设计。

安装

通过 composer 安装此扩展是首选方式。

安装,可以运行

$ php composer.phar require anmaslov/yii2-autocomplete-widget "*"

或者将以下内容添加到您的 composer.json 文件的 require 部分:

"anmaslov/yii2-autocomplete-widget": "*"

to the require section of your composer.json file.

使用方法

从模型获取数据

$data = Link::find()
            ->select('title as value')
            ->asArray()
            ->all();

在视图中

use anmaslov\autocomplete\AutoComplete;

echo AutoComplete::widget([
            'name' => 'link',
            'data' =>  $model,
             'clientOptions' => [
                 'minChars' => 2,
             ],
        ])

许可证

yii2-autocomplete-widgetMIT 许可证 下发布。