You are here

function nodereference_autocomplete_value in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 6.3 modules/nodereference/nodereference.module \nodereference_autocomplete_value()
  2. 6.2 modules/nodereference/nodereference.module \nodereference_autocomplete_value()

Value for a nodereference autocomplete element.

Substitute in the node title for the node nid.

1 string reference to 'nodereference_autocomplete_value'
nodereference_widget in modules/nodereference/nodereference.module
Implementation of hook_widget().

File

modules/nodereference/nodereference.module, line 398
Defines a field type for referencing one node from another.

Code

function nodereference_autocomplete_value($element, $edit = FALSE) {
  $field_key = $element['#columns'][0];
  if (!empty($element['#default_value'][$field_key])) {
    $nid = $element['#default_value'][$field_key];
    $value = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $nid));
    $value .= ' [nid:' . $nid . ']';
    return array(
      $field_key => $value,
    );
  }
  return array(
    $field_key => NULL,
  );
}