ATK4 autocomplete

时间:2017-08-05 11:18:39

标签: php atk4

I created an demo according https://github.com/atk4/money-lending-tutorial/blob/master/tutorial/en/step1.md , it works, but I can not manage to integrate the https://github.com/atk4/autocomplete addon.

Can someone point me to:
1. how can I install it? (I done in via modifiing the composer.json by adding "atk4/autocomplete": "dev-master" and composer install command)
2. how can I autoload/integrate it?
3. how can I use it? The samples says $this->hasOne('User')->display(...);, but no display() function is defined.

1 个答案:

答案 0 :(得分:2)

更新:自动填充功能现已成为Agile UI的一部分

http://ui.agiletoolkit.org/demos/autocomplete.php

可以像以下一样简单:

$form->addField('country3', [
    'AutoComplete',
    'model'       => new Country($db),
    'placeholder' => 'Search for country by code, LV or UK',
    'search'      => ['name', 'iso', 'iso3'],
]);

旧答案

不幸的是," atk4 / autocomplete"与Agile UI / Agile Data不兼容,因此可能需要重写一次。

使用Agile UI实现AutoComplete:

  1. 了解回调和虚拟网页:http://agile-ui.readthedocs.io/en/latest/core.html#callbacks-and-virtual-pages

  2. 了解https://semantic-ui.com/modules/search.html

  3. 使用回调创建自己的自动完成字段类。

  4. 在Agile UI / Data中实现自动完成实际上不应该超过10行代码。