|
|
|
controller:
Schoolgemeenschappen table [id, name] public function schoolgemeenschapAction() { $schoolgemeenschappen = new Schoolgemeenschappen(); $this->_helper->autoCompleteDojoExt($schoolgemeenschappen->fetchAll()->toArray()); } in form: $this->addElement( in add and change record $row->scholengemeenschap_id = $form->getValue('scholengemeenschap_id'); do you understand now? with my new function you get: {"identifier":"name","items":[{"label":"CLB-Kempen","name":"1"},{"label":"CLB-1 AMI","name":"2"}]} with the current you get {"identifier":"name","items":[{"label":"CLB-Kempen","name":"CLB-Kempen"},{"label":"CLB-1 AMI","name":"CLB-1 AMI"}]} because of this code: foreach ($data as $key => $value) {
$items[] = array('label' => $value, 'name' => $value);
} this function keeps the old one working
if one array is given id and name are the same (the old functionality) when you use a multidimensional array it will use my code. <?php
/**
/**
return false; /**
$items = array(); foreach ($data as $key => $value) { $items[] = array('label' => $value, 'name' => $value); } }else{ foreach ($data as $value) { $items[] = array('label' => array_pop($value), 'name' => array_pop($value)); } } $final = array( return $this->encodeJson($final, $keepLayouts); } old json output:
{"identifier":"name","items":[{"label":{"id":"1","vestigingnaam":"Geel"},"name":{"id":"1","vestigingnaam":"Geel"}},{"label":{"id":"2","vestigingnaam":"Mol"},"name":{"id":"2","vestigingnaam":"Mol"}},{"label":{"id":"3","vestigingnaam":"Westerlo"},"name":{"id":"3","vestigingnaam":"Westerlo"}},{"label":{"id":"4","vestigingnaam":"Vorselaar"},"name":{"id":"4","vestigingnaam":"Vorselaar"}},{"label":{"id":"5","vestigingnaam":"Turnhout"},"name":{"id":"5","vestigingnaam":"Turnhout"}},{"label":{"id":"6","vestigingnaam":"Zoersel"},"name":{"id":"6","vestigingnaam":"Zoersel"}},{"label":{"id":"7","vestigingnaam":"Hoogstraten"},"name":{"id":"7","vestigingnaam":"Hoogstraten"}},{"label":{"id":"8","vestigingnaam":"Herentals"},"name":{"id":"8","vestigingnaam":"Herentals"}}]} mine json output: {"identifier":"name","items":[{"label":"Geel","name":"1"},{"label":"Mol","name":"2"},{"label":"Westerlo","name":"3"},{"label":"Vorselaar","name":"4"},{"label":"Turnhout","name":"5"},{"label":"Zoersel","name":"6"},{"label":"Hoogstraten","name":"7"},{"label":"Herentals","name":"8"}]} There is an issue with my multi column detection
when only one row is given the detection uses the old dojo generation code even if it should use mine. So don't use the code which I proposed. Matthew if you need a tester for your code, let me know I'm happy to beta test it. Personnally I just changed 2 few things to get this autocompleteDojo working:
--> added key in the line and changed the 'identifier from 'name' to 'key' Then with this HTML code I get my autocomplete working, showing names and using Id on my form destination:
one more point, for your sub-array detection why don't you use is_array($value) ?
your probably right
how would you do following code? 'onChange'=> "stateStore2 = new dojo.data.ItemFileReadStore({url: '/studiegids/overzichtschool/studierichting/onderwijsvormid/'+ dijit.byId('onderwijsvorm_id').getValue() }); dijit.byId('studierichting_id').store = stateStore2; dijit.byId('studierichting_id').setDisplayedValue('');", I'm not sure of what you're asking for. But I think that if you want to re-query your store you should use soething based on QueryReadStore instead. I wrote an example here:
http://www.makina-corpus.org/2008/10/26/autocomplete-ajax-search-with-dojo-and-zend-framework/ What's the status of this? This gets to be particularly problematic for things such as trying to do State Code => State name mapping with either a ComboBox or FilteringSelect and the only thing being outputted to the screen is just the State name...
The Dojo autocomplete action helper was converted to Zend_Dojo_Data in 1.7.0, released in November 2008. It can either create a Zend_Dojo_Data object, or consume one. If you need to specify different keys for the identifier and/or label, pass your data to a new instance of Zend_Dojo_Data, and then pass that to the helper:
// Use "id" as the identifier, "name" as the label: $data = new Zend_Dojo_Data('id', $items, "name"); $this->_helper->autoCompleteDojo($data); If I do not hear any feedback one way or the other on whether or not the above solution addresses this issue (at this point, I'm not even entirely certain what issue is actually being reported), I will close the bug. |
||||||||||||||||||||||||||||||||||||||||||||||||
For the record, we plan to update the Dojo autocomplete action helper to utilize Zend_Dojo_Data, which will also give more flexibility. I'm also thinking that a flag and/or setters for specifying either FilteringSelect or ComboBox would help make it more useful.