You are here

function userreference_autocomplete in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 5 userreference.module \userreference_autocomplete()
  2. 6.3 modules/userreference/userreference.module \userreference_autocomplete()
  3. 6 modules/userreference/userreference.module \userreference_autocomplete()

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

3 string references to 'userreference_autocomplete'
userreference_menu in modules/userreference/userreference.module
Implementation of hook_menu().
userreference_widget in modules/userreference/userreference.module
Implementation of hook_widget().
userreference_widget_settings in modules/userreference/userreference.module
Implementation of hook_widget_settings().

File

modules/userreference/userreference.module, line 840
Defines a field type for referencing a user from a node.

Code

function userreference_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 = _userreference_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']] = '<div class="reference-autocomplete">' . $row['rendered'] . '</div>';
  }
  drupal_json($matches);
}