function petreference_autocomplete_value in Previewable email templates 6
Value for a petreference autocomplete element.
Substitute in the pet title for the node nid.
1 string reference to 'petreference_autocomplete_value'
- petreference_widget in modules/
petreference/ petreference.module - Implementation of hook_widget().
File
- modules/
petreference/ petreference.module, line 499 - Defines a field type for referencing pet template to a node.
Code
function petreference_autocomplete_value($element, $edit = FALSE) {
$field_key = $element['#columns'][0];
if (!empty($element['#default_value'][$field_key])) {
$pid = $element['#default_value'][$field_key];
$value = db_result(db_query(db_rewrite_sql('SELECT p.title FROM {pets} p WHERE p.pid = %d'), $pid));
$value .= ' [pid:' . $pid . ']';
return array(
$field_key => $value,
);
}
return array(
$field_key => NULL,
);
}