简体   繁体   中英

ATK4 Autocomplete issue

I'm new to ATK4. I'm trying to implement an Autocomplete field, but I had only an error when I try to define the field. I'm running all on a MAC with the last version (4.2.4) of ATK4. All other functions (field types) seems to work well, but when I define a field of type autocomplete I get the same error I saw on the example: http://codepad.agiletoolkit.org/autocomplete

The case is I defined a model:

class Model_Agenda extends Model_Table {
    public $entity_code='Agenda';
    function init(){
        parent::init();

        $this->addField('DATE');
        $this->addField('TIME');
        $this->addField('DRIVERID');
        $this->addField('STUDENTID');
        $this->hasOne('STUDENTID')->display(array('form'=>'autocomplete/Basic'));

    }
}

and then on my Page:

    $form = $this->add('Form');
    $form->addField('ReadOnly','Date')->Set($_GET['date']);
    $form->addField('ReadOnly','Time')->Set($_GET['time']);
    $form->addField('ReadOnly','Driver')->Set($_GET['driverid']);       
    $client=$form->addField('autocomplete','studentid');

something simple, but nothing, I cannot get the autocomplete field, I ever get an error that say that "autocomplete.php" doesn't exist (actually the file doesn't exist and I try to download the github module, but either that module includes this file), anyway the error I get is:

Exception_PathFinder, code: 0

Additional information:

file: Form/Field/Autocomplete.php
type: php
attempted_locations:
0: /Library/WebServer/Documents/rutas/lib/Form/Field/Autocomplete.php
1: /Library/WebServer/Documents/rutas/atk4/lib/Form/Field/Autocomplete.php
2: /Library/WebServer/Documents/rutas/atk4-addons/mvc/Form/Field/Autocomplete.php
3: /Library/WebServer/Documents/rutas/atk4-addons/misc/lib/Form/Field/Autocomplete.php
class: Form_Field_Autocomplete
namespace:
orig_class: Form_Field_Autocomplete
/Library/WebServer/Documents/rutas/atk4/lib/PathFinder.php:207

Someone could help me please?

You're talking about this add-on, right: https://github.com/atk4/autocomplete ?

Looks like issue with PathFinder unable to find appropriate location of namespaced addons. Please post here part of your API_Frontend class where you add additional locations to pathfinder and also tell me something more about your folder structure (in which folder you have put autocomplete add-on files).

ATK 4.2.4 version is not last. Can you try to upgrade ATK to version 4.2.5? It's not officially released, but is available in GitHub master branch here: https://github.com/atk4/atk4 ? I hope everything will work with 4.2.5 version but if not, then I'll help you solve this issue.

And one more thing - if you're creating form fields manually, then you need to set Model for that $client field. I guess it can be done with $client->setModel('Agenda');


EDIT: correct answer

In line

$client=$form->addField('autocomplete','studentid');

you should write full autocomplete field class name with namespace like this:

$client=$form->addField('autocomplete/Basic', 'studentid');

One more thing to note is to use lowercase function name. So instead of Set() use set() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM