You are here

function references_dialog_field_widget_form in References dialog 7

Implements hook_field_widget_form().

File

./references_dialog.module, line 886
This the main module file.

Code

function references_dialog_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  switch ($instance['widget']['type']) {
    case 'references_dialog_term_reference':
      if (isset($items[$delta]['tid'])) {
        $term = taxonomy_term_load($items[$delta]['tid']);
        $value = $term->name;
      }
      else {
        $value = NULL;
      }
      $element += array(
        '#type' => 'textfield',
        '#default_value' => $value,
        '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $field['field_name'],
        '#size' => $instance['widget']['settings']['size'],
        '#maxlength' => NULL,
        '#element_validate' => array(
          'references_dialog_term_reference_autocomplete_validate',
        ),
      );
      break;
  }
  return array(
    'tid' => $element,
  );
}