title: jQuery UI autocomplete + CakePHP
body: <p>I'm setting up jQuery UI autocomplete on a CakePHP site, and feel like I'm missing something really obvious, but it's almost working...</p>
  
  <p>So the simple jQuery code is:</p>
  
  <pre><code>$(function() {
      $("#SearchQuery").autocomplete({
          source: "&lt;?= $session-&gt;base ?&gt;/search/complete",
          minLength: 2
      });
  });
  </code></pre>
  
  <p>This connects to my search controller, and the search controller returns items from the database. I can get the results back if I don't try to actually look at the "term" (what has been typed. So, in my controller this works:</p>
  
  <pre><code>function complete(){
      $entries = $this-&gt;Entry-&gt;find('list');
      $this-&gt;set('entries', $entries);
  }
  </code></pre>
  
  <p>It is returned as JSON, and drops down from the input like it should. But it never narrows the results based on what has been typed. I would think that this should narrow the results:</p>
  
  <pre><code>function complete($query = null){
      $entries = $this-&gt;Entry-&gt;find('list', 
          array('conditions' =&gt; array('title LIKE' =&gt; '%'.$query.'%')));
      $this-&gt;set('entries', $entries);
  }
  </code></pre>
  
  <p>But with this code nothing is ever returned. What am I doing wrong?</p>
  
  <p><strong>P.S.</strong> People who find this question and are having trouble getting the results back to the autocomplete function, be sure you're returning properly formatted JSON results: <a href="http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/" rel="nofollow noreferrer">http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/</a></p>