function tripal_autocomplete_contact

2.x tripal_autocomplete_contact($text)

This function is intended to be used in autocomplete forms for contacts.


$text: The string to search for

Return value

A json array of terms that begin with the provided string

Related topics

1 string reference to 'tripal_autocomplete_contact'
tripal_contact_menu in tripal_contact/tripal_contact.module
Implemets hook_menu(). Adds menu items for the tripal_contact module menu. This section gives the outline for the main menu of the Tripal-contact module


tripal_contact/api/, line 126
Functions to interact with contacts.


function tripal_autocomplete_contact($text) {
  $matches = array();

  $sql = "SELECT * FROM {contact} WHERE lower(name) like lower(:name) ";
  $args = array();
  $args[':name'] = $text . '%';
  $sql .= "ORDER BY name ";
  $sql .= "LIMIT 25 OFFSET 0 ";
  $results = chado_query($sql, $args);
  $items = array();
  foreach ($results as $contact) {
    // Don't include the null contact
    if ($contact->name == 'null') {
    $items[$contact->name] = $contact->name;