Transmiterea datelor către Dojo Filteringselect (cu cod)

I'm quite new to Zend & JSON, however I have the need to learn. What I want to achieve is: having a Dojo filteringselect (with autocomplete) control which is linked to zipcodes from a database (and which keeps track of the ID, so I can store that ID as a FK in another table (later on). The structure is MVC. I do get results from the database, however I can't seem to make it shine. Nothing shows up in the filteringselect control. So basicly the structure field of my database needs to get into the filteringsselect control and keeping track of that id, because I need it later on as a FK in another table. Please help me out!


class Application_Model_Place extends FS_Model_Popo {
protected $_fields = array(
    'id'            => NULL, 
    'zip'      => NULL, 
    'name'          => NULL, 
    'up'            => NULL, 
    'structure'     => NULL);

protected $_primaryKey = array('id');


$place = new Zend_Dojo_Form_Element_FilteringSelect('Place');
    ->setAttrib('title', 'Add a place.')
    ->setStoreParams(array('url' => '/graph/place/autocomplete'))
    ->setAttrib("searchAttr", "structure")


class Graph_PlaceController extends Zend_Controller_Action {
public function autocompleteAction() {
    $structuur = $this->_getParam("structure", "");

    $results = FS_Model_Factory::getInstance()->place->autocomplete(array('structure like ?'=> "%".$structure."%"));
    $enc_res = array();
    foreach ($results as $value) {
    $data = new Zend_Dojo_Data('id', $enc_res);

Un exemplu de json ($ enc_res) ar fi:

{"id":"235","zip":"3130","name":"Betekom","up":"BETEKOM","structure":"3130 Betekom"}, {"id":"268","zip":"3211","name":"Binkom","up":"BINKOM","structure":"3211 Binkom"},{"id":"377","zip":"3840","name":"Broekom","up":"BROEKOM","structure":"3840 Broekom"},{"id":"393","zip":"1081","name":"Brussel (Koekelberg)","up":"BRUSSEL (KOEKELBERG)","structure":"1081 BRUSSEL (KOEKELBERG)"},{"id":"421","zip":"1081","name":"Bruxelles (Koekelberg)","up":"BRUXELLES (KOEKELBERG)","structure":"1081 BRUXELLES (KOEKELBERG)"},{"id":"668","zip":"3670","name":"Ellikom","up":"ELLIKOM","structure":"3670 Ellikom"},{"id":"1236","zip":"3840","name":"Jesseren (Kolmont)","up":"JESSEREN (KOLMONT)","structure":"3840 Jesseren (Kolmont)"},{"id":"1275","zip":"3370","name":"Kerkom","up":"KERKOM","structure":"3370 Kerkom"}

1 răspunsuri

Cred că aveți mai multe opțiuni:

Opțiunea 1 este, evident, cea mai ușoară ...

JavaScript, România - Moldova
JavaScript, România - Moldova
328 participanți

Comunitatea Română JavaScript: Pentru confort, opriți notificările. Parteneri: @node_ro, @php_ro, @python_ro, @seo_ro, @RomaniaGroup, @ai_ro, @Grupuri_IT Offtop: @holywars_ro Joburi: @js_jobs_ro Sponsored with ❤️ by

PHP România, Moldova
PHP România, Moldova
173 participanți

Vorbim despre Yii, Laravel, Symphony, MySQL, PgSQL, WP, OpenCart... Pentru confort, opriți notificările. Parteneri: @js_ro @node_ro @python_ro @seo_ro @Romania_Bot Offtop: @holywars_ro Joburi: @php_job @Grupuri_IT