ATK4 autocomplete

102 views Asked by At

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

There are 1 answers

0
romaninsh On BEST ANSWER

UPDATE: Autocomplete is now part of Agile UI

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

Can be used as easy as:

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

Old answer

Unfortunately, "atk4/autocomplete" is not compatible with Agile UI / Agile Data, so it might need some rewrite.

To implement AutoComplete with Agile UI:

  1. Learn about Callbacks and Virtual pages: http://agile-ui.readthedocs.io/en/latest/core.html#callbacks-and-virtual-pages

  2. Learn about https://semantic-ui.com/modules/search.html

  3. Create your own auto-complete field class with callback.

It shouldn't actually take more than 10 lines of code to implement autocomplete in Agile UI / Data.