You are here

ref_field.module in (Entity)Reference Field Synchronization 7

File

ref_field.module
View source
<?php

// Second that a token should live
define('REFFIELDTIMEOUT', 10800);

/**
 * Implements hook_help().
 */
function ref_field_help($path, $arg) {
  switch ($path) {
    case 'admin/help#ref_field':
      return '<p>' . t('Reference field lets you create fields to reference entities. Each field can reference one king of entity, and will optionaly let you limit the bundles that can be referenced.') . '</p>';
  }
}

/**
 * Implements hook_menu().
 */
function ref_field_menu() {
  $items = array();
  $items['ref_field/autocomplete/%/%/%/%'] = array(
    'page callback' => '_ref_fieldl_autocomplete',
    'page arguments' => array(
      2,
      3,
      4,
      5,
    ),
    'access callback' => '_ref_fieldl_autocomplete_access',
    'access arguments' => array(
      2,
      3,
      4,
      5,
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implements hook_field_info().
 */
function ref_field_field_info() {
  return array(
    'ref_field' => array(
      'label' => t('Entity reference'),
      'description' => t('This field stores a directional reference between two entities.'),
      'settings' => array(
        'entity' => '',
        'bundles' => array(),
      ),
      'default_widget' => 'ref_field_autocomplete',
      'default_formatter' => 'ref_field_title',
      'property_callbacks' => array(
        'ref_field_field_property_callback',
      ),
    ),
  );
}

/**
 * Implements hook_field_settings_form().
 *
 * @see ref_field_form_field_ui_field_settings_form_alter().
 *   The ajax update needs to be done on a hook_form_FORM-ID_alter().
 */
function ref_field_field_settings_form($field, $instance, $has_data) {
  $form = array();
  $options = array(
    '' => t('- Select -'),
  );
  foreach (entity_get_info() as $entity => $data) {
    $options[$entity] = $data['label'];
  }
  if (!$has_data) {

    // Show entities and bundles in two fields
    // One field can get too large
    $form['entity'] = array(
      '#title' => t('Entity'),
      '#description' => t('Select the entity type this field will reference.'),
      '#type' => 'select',
      '#default_value' => isset($field['settings']['entity']) ? $field['settings']['entity'] : '',
      '#required' => TRUE,
      '#ajax' => array(
        'callback' => '_ref_field_field_settings_ajax',
        'wrapper' => '',
      ),
      '#element_validate' => array(
        '_ref_field_field_entity_settings_form_validate',
      ),
      '#options' => $options,
    );
  }
  $form['bundles'] = array();
  _ref_field_field_settings_bundles($form['bundles'], $field['settings']['entity'], $has_data);
  return $form;
}

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 *
 * This hook modifies the options for the "bundle" option
 * It is here because of the ajax update. We do not have $form_state on
 * hook_field_settings_form().
 */
function ref_field_form_field_ui_field_settings_form_alter(&$form, &$form_state, $form_id) {
  $has_data = isset($form['#field']) ? field_has_data($form['#field']) : FALSE;
  if ($form['field']['type']['#value'] == 'ref_field' && isset($form_state['values']['field']['settings']['entity'])) {
    _ref_field_field_settings_bundles($form['field']['settings']['bundles'], $form_state['values']['field']['settings']['entity'], $has_data);
  }
  $form['field']['settings']['entity']['#ajax']['wrapper'] = $form['#id'];
}
function ref_field_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#field']['type'] == 'ref_field' && isset($form_state['values']['field']['settings']['entity'])) {
    _ref_field_field_settings_bundles($form['field']['settings']['bundles'], $form_state['values']['field']['settings']['entity'], field_has_data($form['#field']));
  }
  $form['field']['settings']['entity']['#ajax']['wrapper'] = $form['#id'];
}

/**
 * Set the bundle field for a ref_field
 * @param $element
 *   The form element to set field on
 * @param $entity
 *   The entity which bundles are going to be the options
 * @param $has_data
 *   (boolean) Whether the field has data any data. @see field_has_data().
 */
function _ref_field_field_settings_bundles(&$element, $entity, $has_data) {
  $options = array();
  $entity_info = entity_get_info($entity);
  switch ($entity) {
    case FALSE || NULL:
    case 'comment':
      break;
    case 'taxonomy_term':

      // Special case for taxonomy_term
      // http://api.drupal.org/api/drupal/includes--entity.inc/function/EntityFieldQuery%3A%3AentityCondition/7
      foreach ($entity_info['bundles'] as $bundle => $data) {
        $vocabulary = taxonomy_vocabulary_machine_name_load($bundle);
        $options[$vocabulary->vid] = $data['label'];
      }
      break;
    default:
      foreach ($entity_info['bundles'] as $bundle => $data) {
        $options[$bundle] = $data['label'];
      }
      break;
  }
  if ($options) {
    $warning = t('Changes made here might cause loss of data, use with caution.');
    $description = t('Select the bundles you want to reference with this field. If none is selected, every bundle will be referenceable.');
    $element = array(
      '#title' => t('Bundles'),
      '#description' => $has_data ? $warning . ' ' . $description : $description,
      '#type' => 'select',
      '#multiple' => TRUE,
      '#default_value' => isset($field['settings']['bundles']) ? $field['settings']['bundles'] : '',
      '#element_validate' => array(
        '_ref_field_field_bundles_settings_form_validate',
      ),
      '#options' => $options,
    );
  }
  else {
    $element = array();
  }
}

/**
 * Ajax callback for settings form. Return bundle settings field.
 */
function _ref_field_field_settings_ajax(&$form, &$form_state) {
  return $form;
}
function _ref_field_field_entity_settings_form_validate($element, $form_state, $form) {
  if (!entity_get_info($element['#value'])) {
    form_error($element, t('Invalid entity selected'));
  }
}

/**
 * Implements hook_field_instance_settings_form().
 */
function ref_field_field_instance_settings_form($field, $instance) {
  $form = array();
  return $form;
}
function _ref_field_field_bundles_settings_form_validate($element, &$form_state, $form) {

  // Make sure the bundles selected exist within the selected entity
  if (isset($form_state['values']['field']['settings']['entity'])) {
    $entity = $form_state['values']['field']['settings']['entity'];
  }
  else {
    $entity = $form['#field']['settings']['entity'];
  }
  $entity_info = entity_get_info($entity);
  $error = FALSE;
  switch ($entity) {
    case FALSE || NULL:
      break;
    case 'comment':
      break;
    case 'taxonomy_term':

      // Special case for taxonomy_term
      // http://api.drupal.org/api/drupal/includes--entity.inc/function/EntityFieldQuery%3A%3AentityCondition/7
      foreach ($element['#value'] as $vid) {
        $vocabulary = taxonomy_vocabulary_load($vid);
        if (!isset($entity_info['bundles'][$vocabulary->machine_name])) {
          $error = TRUE;
        }
      }
      break;
    default:
      foreach ($element['#value'] as $bundle) {
        if (!isset($entity_info['bundles'][$bundle])) {
          $error = TRUE;
        }
      }
      break;
  }

  // This should not happen if ajax is working correctly
  // Bundle options are updated via ajax
  if ($error) {
    form_error($element, t('Invalid bundles selected. If trying to change the entity type and are getting this error, please use the "Field Settings" tab instead.'));
  }
}

/**
 * Implements hook_field_validate().
 *
 * Possible error codes:
 * - 'ref_field_invalid_rel': The given id is not from a valid 'entity'.
 * - 'ref_field_auto_reference': Self reference detected.
 */
function ref_field_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  $entity_info = entity_get_info($entity_type);
  foreach ($items as $delta => $item) {
    if ($item['eid'] && !entity_load($field['settings']['entity'], array(
      $item['eid'],
    ))) {
      $errors[$field['field_name']][$langcode][$delta][] = array(
        'error' => 'ref_field_invalid_rel',
        'message' => t('%name: you selected an invalid %entity.', array(
          '%name' => $instance['label'],
          '%entity' => $field['settings']['entity'],
        )),
      );
    }
    if ($field['settings']['entity'] == $entity_type && $item['eid'] && $item['eid'] == $entity->{$entity_info}['entity keys']['id']) {
      $errors[$field['field_name']][$langcode][$delta][] = array(
        'error' => 'ref_field_auto_reference',
        'message' => t('%name: self-reference are not allowed, please change the value.', array(
          '%name' => $instance['label'],
        )),
      );
    }
  }
}

/**
 * Implements hook_field_widget_error().
 */
function ref_field_field_widget_error($element, $error, $form, &$form_state) {
  form_error($element['eid'], $error['message']);
}

/**
 * Implements hook_field_is_empty().
 */
function ref_field_field_is_empty($item, $field) {
  if (empty($item['eid'])) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Implements hook_field_formatter_info().
 */
function ref_field_field_formatter_info() {
  return array(
    'ref_field_id' => array(
      'label' => t('Entity id'),
      'description' => t('Display the ID of the referenced entity'),
      'field types' => array(
        'ref_field',
      ),
      'settings' => array(
        'linked' => TRUE,
      ),
    ),
    'ref_field_title' => array(
      'label' => t('Entity title'),
      'description' => t('Display the title of the referenced entity'),
      'field types' => array(
        'ref_field',
      ),
      'settings' => array(
        'linked' => TRUE,
      ),
    ),
  );
}

/**
 * Implements hook_field_formatter_settings_form().
 */
function ref_field_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $element = array();
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  switch ($display['type']) {
    case 'ref_field_id':
    case 'ref_field_title':
      $element['linked'] = array(
        '#type' => 'checkbox',
        '#default_value' => $settings['linked'],
        '#title' => t('Link to content'),
      );
      break;
  }
  return $element;
}

/**
 * Implements hook_field_formatter_settings_summary().
 */
function ref_field_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = '';
  switch ($display['type']) {
    case 'ref_field_id':
    case 'ref_field_title':
      if ($display['settings']['linked']) {
        $summary .= t('Linked to content');
      }
      else {
        $summary .= t('Not linked to content');
      }
      break;
  }
  return $summary;
}

/**
 * Implements hook_field_formatter_prepare_view().
 */
function ref_field_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  $target_ids = array();

  // Collect every possible entity attached to any of the entities.
  foreach ($entities as $id => $entity) {
    foreach ($items[$id] as $delta => $item) {
      $target_ids[] = $item['eid'];
    }
  }
  if ($target_ids) {
    $target_entities = entity_load($field['settings']['entity'], $target_ids);

    // Iterate through the fieldable entities again to attach the loaded data.
    foreach ($entities as $id => $entity) {
      $rekey = FALSE;
      foreach ($items[$id] as $delta => $item) {

        // Check whether the referenced entity could be loaded.
        if (isset($target_entities[$item['eid']])) {

          // Replace the instance value with the term data.
          $items[$id][$delta]['entity'] = $target_entities[$item['eid']];
        }
        else {
          unset($items[$id][$delta]);
          $rekey = TRUE;
        }
      }
      if ($rekey) {

        // Rekey the items array.
        $items[$id] = array_values($items[$id]);
      }
    }
  }
}

/**
 * Implements hook_field_formatter_view().
 */
function ref_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'ref_field_id':
      foreach ($items as $delta => $item) {
        $e = $item['entity'];
        $e_type = $field['settings']['entity'];
        $output = $item['eid'];

        // Link to content if setting is selecetd
        if ($display['settings']['linked']) {
          $uri = entity_uri($e_type, $e);
          $output = l($output, $uri['path'], $uri['options']);
        }
        $element[$delta] = array(
          '#markup' => $output,
        );
      }
      break;
    case 'ref_field_title':
      foreach ($items as $delta => $item) {
        $e = $item['entity'];
        $e_type = $field['settings']['entity'];
        $output = entity_label($e_type, $e);

        // Link to content if setting is selecetd
        if ($display['settings']['linked']) {
          $uri = entity_uri($e_type, $e);
          $output = l($output, $uri['path'], $uri['options']);
        }
        $element[$delta] = array(
          '#markup' => $output,
        );
      }
      break;
  }
  return $element;
}

/**
 * Implements hook_field_widget_info_alter().
 */
function ref_field_field_widget_info_alter(&$info) {
  $info['options_select']['field types'][] = 'ref_field';
  $info['options_buttons']['field types'][] = 'ref_field';
}

/**
 * Implements hook_options_list().
 */
function ref_field_options_list($field) {
  return _ref_field_get_referenceable_entities($field);
}

/**
 * Implements hook_field_widget_info().
 */
function ref_field_field_widget_info() {
  return array(
    'ref_field_autocomplete' => array(
      'label' => t('Autocomplete'),
      'field types' => array(
        'ref_field',
      ),
      'behaviors' => array(
        'default value' => FIELD_BEHAVIOR_NONE,
      ),
    ),
  );
}

/**
 * Implements hook_field_widget_form().
 */
function ref_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  // Get the ID
  $eid = isset($items[$delta]['eid']) ? $items[$delta]['eid'] : '';
  $entity_type = $field['settings']['entity'];

  // Load the entity
  $default_value = '';
  if ($eid) {
    $entity = entity_load($entity_type, array(
      $eid,
    ));

    // Format default value
    $default_value = $entity ? ref_field_encode($entity_type, $entity[$eid]) : '';
  }

  // Set a token with the timestamp with the time the user accesed the widget
  // This is used to check access to the autocomplete path
  $_SESSION['ref_field'][$instance['id']] = time();
  $element += array(
    '#type' => 'textfield',
    '#default_value' => $default_value,
    '#autocomplete_path' => 'ref_field/autocomplete/' . $instance['id'] . '/' . $instance['field_name'] . '/' . $instance['entity_type'] . '/' . $instance['bundle'],
  );

  // Autocomplete is only compatible with entities that can have labels
  // @see hook_entity_info().
  // @see entity_label().
  $entity_info = entity_get_info($entity_type);
  if ($entity_type != 'user' && !isset($entity_info['entity keys']['label'])) {
    drupal_set_message(t('%instance: Autocomplete is not compatible with %entity_type entities, please contact your administrator.', array(
      '%instance' => $instance['label'],
      '%entity_type' => $entity_info['label'],
    )), 'error');
  }
  $element['#element_validate'][] = 'ref_field_field_widget_validate';
  return array(
    'eid' => $element,
  );
}

/**
 * FAPI validation of an individual element.
 */
function ref_field_field_widget_validate($element, &$form_state) {

  // Save previous references to ensure uniqueness
  static $previous = array();
  $error = TRUE;

  // Get field definition
  $field = field_widget_field($element, $form_state);

  // Get instance definition
  $instance = field_widget_instance($element, $form_state);

  // Extract the IDs
  $matches = ref_field_decode($element['#value']);
  if (!empty($element['#value']) && isset($matches['id'])) {

    // If already referenced, give error
    if (isset($previous[$element['#field_name']]) && in_array($matches['id'], $previous[$element['#field_name']])) {
      form_error($element, t('References must be unique, you already references this entity.'));
      $error = TRUE;
    }
    elseif ($entity = entity_load($matches['entity_type'], array(
      $matches['id'],
    ))) {

      // Set value to the ID
      form_set_value($element, $matches['id'], $form_state);
      $previous[$element['#field_name']][] = $matches['id'];
    }
  }

  //  if (!empty($element['#value']) && !isset($entity)) {
  //    form_error($element, t('You selected an invalid entity'));
  //    $error = TRUE;
  //  }
}
function _ref_fieldl_autocomplete_access($instance_id, $field_name, $entity_type, $bundle_name) {
  $field = field_info_field($field_name);
  $instance = field_info_instance($entity_type, $field_name, $bundle_name);
  if ($field && $instance && field_access('edit', $field, $entity_type)) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Autocomplete function for entities.
 * Searches in label field of the entity.
 *
 * @param $instance_id
 *  The instance ID for the given instance. This is ues to check if user came
 *  a form that displayed the widget in the last 3 hours. If so access is
 *  allowed. Stored in $_SESSION['ref_field'][$token].
 * @param $field_name
 *  Name for the current field
 * @param $entity_type
 *  Entity type which this field is attached to
 * @param $budnle_name
 *  Bundle name which this field is attached to
 * @param $string
 *   Text to search for
 *
 * @return
 *   associative array suitable for autocomplete fields where:
 *     - key: value as returned by ref_field_encode().
 *     - value: Entity label
 *
 * @see ref_field_encode().
 */
function _ref_fieldl_autocomplete($instance_id, $field_name, $entity_type, $bundle_name, $string = '') {

  // Unset old tokens
  if (isset($_SESSION['ref_field'])) {
    foreach ($_SESSION['ref_field'] as $id => $instance_time) {
      if ($_SESSION['ref_field'][$id] < time() - REFFIELDTIMEOUT) {
        unset($_SESSION['ref_field'][$id]);
      }
    }
  }

  // If we got here but token does not exists, probably means the token was old
  if (isset($_SESSION['ref_field'][$instance_id])) {
    $field = field_info_field($field_name);

    // Type of entity to autocomplete
    $ref_entity_type = $field['settings']['entity'];

    // Bundles to filter by
    $ref_bundles = $field['settings']['bundles'];

    // Initialize array to store autocomplete matches
    $matches = array();
    $ref_entity_info = entity_get_info($ref_entity_type);
    if ($string && $ref_entity_info) {
      $ref_base_table = $ref_entity_info['base table'];
      $ref_id_column = $ref_entity_info['entity keys']['id'];
      $ref_label_column = FALSE;
      if (isset($ref_entity_info['entity keys']['label'])) {
        $ref_label_column = $ref_entity_info['entity keys']['label'];
      }
      elseif ($ref_entity_type == 'user') {
        $ref_label_column = 'name';
      }

      // Autocomplete is only compatible with entities that have labels column
      // @see hook_entity_info().
      // @see entity_label().
      if ($ref_label_column) {
        $query = new EntityFieldQuery();
        $query
          ->entityCondition('entity_type', $ref_entity_type);
        if ($ref_bundles) {
          switch ($ref_entity_type) {
            case 'taxonomy_term':

              // Special case for taxonomy_term
              // http://api.drupal.org/api/drupal/includes--entity.inc/function/EntityFieldQuery%3A%3AentityCondition/7
              $query
                ->propertyCondition('vid', $ref_bundles, 'IN');
              break;
            default:
              $query
                ->entityCondition('bundle', $ref_bundles, 'IN');
              break;
          }
        }
        $query
          ->propertyCondition($ref_label_column, db_like($string), 'CONTAINS');

        // Should we limit?
        $results = $query
          ->range(0, 10)
          ->execute();
        $ref_entities = entity_load($ref_entity_type, array_keys($results[$ref_entity_type]));
        foreach ($ref_entities as $ref_entity) {
          $matches[ref_field_encode($ref_entity_type, $ref_entity)] = entity_label($ref_entity_type, $ref_entity);
        }
      }
      else {
        $matches[t('error')] = t('Autocomplete is not compatible<br />with %entity_type entities,<br />please contact your administrator.', array(
          '%entity_type' => $ref_entity_info['label'],
        ));
      }
    }
  }
  else {

    // Show a please refresh message if user didn't access the widget in the
    // last x hours
    // Short lines to make sure it fits in short input fields
    $matches[t('error')] = t('Please refresh the form to<br />get access to the autocomplete.<br />If error persist, you may not have<br />access to this autocomplete\'s content.');
  }
  drupal_json_output($matches);
}

/**
 * Returns a user fiendly verison of the ref_field value
 * suitable for autocomplete form fields
 *
 * @param $entity_info
 *   The entity type to format
 * @param $entity
 *   The entity object to format
 *
 * @return
 *   The value that should be returned by a form
 */
function ref_field_encode($entity_type, $entity) {

  // Get the entity info
  $entity_info = entity_get_info($entity_type);
  $id_column = $entity_info['entity keys']['id'];
  return entity_label($entity_type, $entity) . ' | ' . $entity_type . ':' . $entity->{$id_column};
}

/**
 * Returns machine friendly information for a ref_field
 * autocomplete form field
 *
 * @param $value
 *   A string as returned by ref_field_encode().
 *
 * @return
 *   An associative array containing:
 *    - entity_type: the entity type
 *    - id: the entity ID
 *   Or FALSE if not match was found
 */
function ref_field_decode($value) {
  $matches = array();
  preg_match('`\\| ([a-z_]+):([0-9]+)$`', $value, $matches);
  $return = FALSE;

  // Check for a valid match
  if (isset($matches[1]) && isset($matches[2])) {
    $return = array(
      'entity_type' => $matches[1],
      'id' => $matches[2],
    );
  }
  return $return;
}

/**
 * Return the labels of referenceable entities matching some criteria.
 */
function _ref_field_get_referenceable_entities($field) {
  $options = array();
  $entity_type = $field['settings']['entity'];
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $entity_type);
  if ($field['settings']['bundles']) {
    switch ($field['settings']['entity']) {
      case 'comment':
        break;
      case 'taxonomy_term':

        // Special case for taxonomy_term
        // http://api.drupal.org/api/drupal/includes--entity.inc/function/EntityFieldQuery%3A%3AentityCondition/7
        $query
          ->propertyCondition('vid', $field['settings']['bundles'], 'IN');
        break;
      default:
        $query
          ->entityCondition('bundle', $field['settings']['bundles'], 'IN');
        break;
    }
  }
  $results = $query
    ->execute();
  if (!empty($results[$entity_type])) {
    $entities = entity_load($entity_type, array_keys($results[$entity_type]));
    foreach ($entities as $entity_id => $entity) {
      $options[$entity_id] = entity_label($entity_type, $entity);
    }
  }
  return $options;
}

/**
 * Property callback for the Entity Metadata framework.
 */
function ref_field_field_property_callback(&$info, $entity_type, $field, $instance, $field_type) {

  // Set the property type based on the targe type.
  $field_type['property_type'] = $field['settings']['entity'];

  // Then apply the default.
  entity_metadata_field_default_property_callback($info, $entity_type, $field, $instance, $field_type);
}

/**
 * Implements hook_node_type_update().
 *
 * When a content type (node bundle) name is changed, settings for fields that
 * can reference it must change to reflect the new name.
 */
function ref_field_node_type_update($info) {
  if (!empty($info->old_type) && $info->old_type != $info->type) {
    $fields = field_read_fields(array(
      'type' => 'ref_field',
    ));
    foreach ($fields as $field_name => $field) {
      if ($field['settings']['entity'] == 'node' && isset($field['settings']['bundles'][$info->old_type])) {
        $field['settings']['bundles'][$info->type] = $info->type;
        unset($field['settings']['bundles'][$info->old_type]);
        field_update_field($field);
      }
    }
  }
}
function ref_field_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'ref_field') . '/includes/views',
  );
}

Functions

Namesort descending Description
ref_field_decode Returns machine friendly information for a ref_field autocomplete form field
ref_field_encode Returns a user fiendly verison of the ref_field value suitable for autocomplete form fields
ref_field_field_formatter_info Implements hook_field_formatter_info().
ref_field_field_formatter_prepare_view Implements hook_field_formatter_prepare_view().
ref_field_field_formatter_settings_form Implements hook_field_formatter_settings_form().
ref_field_field_formatter_settings_summary Implements hook_field_formatter_settings_summary().
ref_field_field_formatter_view Implements hook_field_formatter_view().
ref_field_field_info Implements hook_field_info().
ref_field_field_instance_settings_form Implements hook_field_instance_settings_form().
ref_field_field_is_empty Implements hook_field_is_empty().
ref_field_field_property_callback Property callback for the Entity Metadata framework.
ref_field_field_settings_form Implements hook_field_settings_form().
ref_field_field_validate Implements hook_field_validate().
ref_field_field_widget_error Implements hook_field_widget_error().
ref_field_field_widget_form Implements hook_field_widget_form().
ref_field_field_widget_info Implements hook_field_widget_info().
ref_field_field_widget_info_alter Implements hook_field_widget_info_alter().
ref_field_field_widget_validate FAPI validation of an individual element.
ref_field_form_field_ui_field_edit_form_alter
ref_field_form_field_ui_field_settings_form_alter Implements hook_form_BASE_FORM_ID_alter().
ref_field_help Implements hook_help().
ref_field_menu Implements hook_menu().
ref_field_node_type_update Implements hook_node_type_update().
ref_field_options_list Implements hook_options_list().
ref_field_views_api
_ref_fieldl_autocomplete Autocomplete function for entities. Searches in label field of the entity.
_ref_fieldl_autocomplete_access
_ref_field_field_bundles_settings_form_validate
_ref_field_field_entity_settings_form_validate
_ref_field_field_settings_ajax Ajax callback for settings form. Return bundle settings field.
_ref_field_field_settings_bundles Set the bundle field for a ref_field
_ref_field_get_referenceable_entities Return the labels of referenceable entities matching some criteria.

Constants

Namesort descending Description
REFFIELDTIMEOUT