You are here

function accordions_autocomplete in Accordions 7

Accordions autocomplete menu callback.

1 string reference to 'accordions_autocomplete'
accordions_menu in ./accordions.module
Implements hook_menu().

File

./accordions.module, line 133

Code

function accordions_autocomplete($string = '') {
  $matches = array();
  if ($string) {
    $result = db_select('accordions', 'a')
      ->fields('a', array(
      'name',
    ))
      ->condition('name', db_like($string) . '%', 'LIKE')
      ->range(0, 10)
      ->execute();
    foreach ($result as $accordion) {
      $matches[$accordion->name] = check_plain($accordion->name);
    }
  }
  drupal_json_output($matches);
}