Пример #1
0
 /**
   * Use this method in your view to generate a return for the AJAX autocomplete requests.
   *
   * Example action:
   *
   *   function auto_complete_for_item_title()
   *   {
   *     $this->items = $Item->find('all', array('conditions' => array('strtolower($description).' LIKE ?', '%' . strtolower($this->_controller->Request->getRawPostData(). '%' ))))
   *     return $this->_controller->render(array('inline'=> '<?= $javascript_macros->auto_complete_result(@$items, 'description') ?>'));
   *   }
   *
   * The auto_complete_result can of course also be called from a view belonging to the 
   * auto_complete action if you need to decorate it further.
   *
   * @deprecated 
   */
 function auto_complete_result($entries, $field, $phrase = null)
 {
     if (empty($entries)) {
         return '';
     }
     foreach ($entries as $entry) {
         $items[] = TagHelper::content_tag('li',!empty($phrase) ? TextHelper::highlight(TextHelper::h($entry[$field]), $phrase) : TextHelper::h(@$entry[$field]));
     }
     return TagHelper::content_tag('ul', join('', array_unique($items)));
 }