nepada/autocomplete-input 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nepada/autocomplete-input

最新稳定版本:v1.3.3

Composer 安装命令:

composer require nepada/autocomplete-input

包简介

Autocomplete text input for Nette forms.

README 文档

README

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

$ composer require nepada/autocomplete-input

Option A: install form container extension method via DI extension

extensions:
    - Nepada\Bridges\AutocompleteInputDI\AutocompleteInputExtension

It will register extension method addAutocomplete($name, $label, callable $dataSource): AutocompleteInput to Nette\Forms\Container.

Option B: use trait in your base form/container class

You can also use AutocompleteInputMixin trait in your base form/container class to add method addAutocomplete($name, $label, callable $dataSource): AutocompleteInput.

Example:

trait FormControls
{

    use Nepada\Bridges\AutocompleteInputForms\AutocompleteInputMixin;

    public function addContainer($name)
    {
        $control = new Container;
        $control->setCurrentGroup($this->getCurrentGroup());
        if ($this->currentGroup !== null) {
            $this->currentGroup->add($control);
        }
        return $this[$name] = $control;
    }

}

class Container extends Nette\Forms\Container
{

    use FormControls;

}

class Form extends Nette\Forms\Form
{

    use FormControls;

}

Usage

AutocompleteInput is a standard text input from Nette enhanced with the autocomplete feature. The input exposes URL to retrieve the entries matching a specified query - you need to pass data source callback when creating the input:

$autocompleteInput = $form->addAutocomplete('foo', 'Foo', function (string $query) {
    // return entries matching the query
});
$autocompleteInput->setAutocompleteMinLength(3); // set minimum input length to trigger autocomplete

Client side

The backend form control is not tightly coupled to any specific client side implementation. The rendered input contains data attributes with all the necessary settings:

<input type="text" name="foo"
    data-autocomplete-query-placeholder="__QUERY_PLACEHOLDER__"
    data-autocomplete-url="/some-url/?do=form-foo-autocomplete&form-foo-query=__QUERY_PLACEHOLDER__"
    data-autocomplete-min-length="3"
>
<!--
    data-autocomplete-min-length is optional
-->

If you do not want to roll out your own client side solution, try @nepada/autocomplete-input npm package.

统计信息

  • 总下载量: 11.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-04-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固