phpatk4

ATK4 autocomplete


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.


Solution

  • 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.