You are here

function og_field_audience_autocomplete in Organic groups 7

Menu callback for the autocomplete results.

1 string reference to 'og_field_audience_autocomplete'
og_menu in ./og.module
Implements hook_menu().

File

./og.field.inc, line 834
Field module functionality for the Organic groups module.

Code

function og_field_audience_autocomplete($field_name, $string = '') {
  $field = field_info_field($field_name);
  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
  $matches = array();
  $groups = og_field_audience_potential_groups($string, $match, array(), 10);
  foreach ($groups as $gid => $label) {

    // Add a class wrapper for a few required CSS overrides.
    $matches[$label . " [gid:{$gid}]"] = '<div class="group-autocomplete">' . $label . '</div>';
  }
  drupal_json_output($matches);
}