You are here

function text_noderef_field_widget_form in Text or Nodereference 7

Implements hook_field_widget_form().

File

./text_noderef.module, line 155
Text or nodereference field formatter for a text field and autocomplete widget.

Code

function text_noderef_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  if ($instance['widget']['type'] == 'text_noderef_textfield') {

    // Reusing text_textfield widget type from text.module, then adding the
    // autocomplete stuff.
    $instance['widget']['type'] = 'text_textfield';
    $element = text_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
    $element['value']['#autocomplete_path'] = 'text_noderef/' . $element['#bundle'] . '/' . $element['#field_name'];
  }
  return $element;
}