Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function _cities_autocomplete($string) {
  2. $matches = array();
  3. $result = db_select('Route', 'c')
  4. ->fields('c', array('Location'))
  5. ->condition('Location', '%' . db_like($string) . '%', 'LIKE')
  6. ->execute();
  7.  
  8. // save the query to matches
  9. foreach ($result as $row) {
  10. $matches[$row->Location] = check_plain($row->Location);
  11. }
  12. // Return the result to the form in json
  13. drupal_json_output($matches);
  14. // print(drupal_json_output($matches));
  15.  
  16. }
  17.  
  18. $form['op']['#autocomplete_path'] = 'cities/autocomplete';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement