You are here

function petreference_autocomplete in Previewable email templates 6

Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users

3 string references to 'petreference_autocomplete'
petreference_menu in modules/petreference/petreference.module
Implementation of hook_menu().
petreference_widget in modules/petreference/petreference.module
Implementation of hook_widget().
petreference_widget_settings in modules/petreference/petreference.module
Implementation of hook_widget_settings().

File

modules/petreference/petreference.module, line 892
Defines a field type for referencing pet template to a node.

Code

function petreference_autocomplete($field_name, $string = '') {
  $fields = content_fields();
  $field = $fields[$field_name];
  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
  $matches = array();
  $references = _petreference_potential_references($field, $string, $match, array(), 10);
  foreach ($references as $id => $row) {

    // Add a class wrapper for a few required CSS overrides.
    $matches[$row['title'] . " [pid:{$id}]"] = '<div class="reference-autocomplete">' . $row['rendered'] . '</div>';
  }
  drupal_json($matches);
}