function rolereference_autocomplete in Role Reference 6
Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing roles
5 string references to 'rolereference_autocomplete'
- rolereference_content_multigroup_allowed_widgets in ./
rolereference.module - Implementation of hook_content_multigroup_allowed_widgets().
- rolereference_content_multigroup_no_remove_widgets in ./
rolereference.module - Implementation of hook_content_multigroup_no_remove_widgets().
- rolereference_menu in ./
rolereference.module - Implementation of hook_menu().
- rolereference_widget in ./
rolereference.module - Implementation of hook_widget().
- rolereference_widget_settings in ./
rolereference.module - Implementation of hook_widget_settings().
File
- ./
rolereference.module, line 837 - Defines a field type for referencing a role. Based almost entirely on nodereference and userreference modules.
Code
function rolereference_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 = _rolereference_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'] . " [rid:{$id}]"] = '<div class="reference-autocomplete">' . $row['rendered'] . '</div>';
}
drupal_json($matches);
}