More times than I’d prefer, I have seen some really good integration between ZF and jQuery UI be (this close) to awesome. In this case, it’s with the AutoComplete form element.
As an example, lets say we were doing a user search. The jQuery UI AutoComplete source results is expected to be an array like this:
- [
- { id: 1, value: 1, name: 'Bob' },
- { id: 2, value: 2, name: 'Borat' }
- ]
When using the JSON context switch helper, you might set your auto complete results like this:
- $this->view->results = $mySearchResults;
As you may have seen, that’s not exactly what we want. I’ve seen some solutions that handle this in the javascript by modifying the “parse” function, but it’s far simpler to do this:
- $this->view->assign($mySearchResults);
This will give you the JSON result formatted as required by the jQuery UI AutoComplete plugin.


