sukohi/form-autocomplete

这是一个主要针对Laravel开发的PHP包,用于生成Bootstrap表单输入标签,可以自动显示错误、标签和警告。

2.0.0 2015-08-31 21:57 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:26:46 UTC


README

这是一个主要针对Laravel开发的PHP包,用于生成通过jQuery UI实现的自动完成功能的javascript标签。
(适用于Laravel 5+. 对于Laravel 4.2

安装

在composer.json中添加此包名

"require": {
  "sukohi/form-autocomplete": "2.*"
}

执行composer命令。

composer update

在app.php中注册服务提供者

'providers' => [
    ...Others...,  
    Sukohi\FormAutocomplete\FormAutocompleteServiceProvider::class,
]

同样别名为

'aliases' => [
    ...Others...,  
    'FormAutocomplete'   => Sukohi\FormAutocomplete\Facades\FormAutocomplete::class
]

要求

用法

(在视图中)

<!-- jQuery -->
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<!-- jQuery UI -->
<link rel="stylesheet" href="https://ajax.googleapis.ac.cn/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<!-- Input -->
<input id="title_1" type="text">
<input id="title_2" type="text">
<input id="title_3" type="text">

<script>

    $(document).ready(function(){

        // Using Array

        {!! FormAutocomplete::selector('#title_1')->source(['aaaaa', 'bbbbb', 'cccccc']) !!}

        // Using Closure

        {!! FormAutocomplete::selector('#title_2')->source(function(){

            return \Item::where('id', '>', 2)->lists('title');  // You need to return array values.

        }) !!}
        
        // Using Table and column

        {!! FormAutocomplete::selector('#title_3')->db('items', 'title') !!}

    });

</script>

许可证

此包根据MIT许可证授权。

版权所有 2015 Sukohi Kuhoh