You are here

function rolereference_autocomplete_value in Role Reference 6

Value for a rolereference autocomplete element.

Substitute in the role name for the role rid.

1 string reference to 'rolereference_autocomplete_value'
rolereference_widget in ./rolereference.module
Implementation of hook_widget().

File

./rolereference.module, line 442
Defines a field type for referencing a role. Based almost entirely on nodereference and userreference modules.

Code

function rolereference_autocomplete_value($element, $edit = FALSE) {
  $field_key = $element['#columns'][0];
  if (!empty($element['#default_value'][$field_key])) {
    $rid = $element['#default_value'][$field_key];
    $value = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid));
    $value .= ' [rid:' . $rid . ']';
    return array(
      $field_key => $value,
    );
  }
  return array(
    $field_key => NULL,
  );
}