You are here

function node_reference_field_formatter_settings_form in References 7.2

Implements hook_field_formatter_settings_form().

File

node_reference/node_reference.module, line 333
Defines a field type for referencing one node from another.

Code

function node_reference_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  switch ($display['type']) {
    case 'node_reference_node':
      $entity_info = entity_get_info('node');
      $modes = $entity_info['view modes'];
      $options = array();
      foreach ($modes as $name => $mode) {
        $options[$name] = $mode['label'];
      }
      $element['node_reference_view_mode'] = array(
        '#title' => t('View mode'),
        '#type' => 'select',
        '#options' => $options,
        '#default_value' => $settings['node_reference_view_mode'],
      );
      break;
    case 'node_reference_path':
      $element['alias'] = array(
        '#type' => 'checkbox',
        '#title' => t('Display the aliased path (if exists) instead of the system path'),
        '#default_value' => $settings['alias'],
      );
      $element['absolute'] = array(
        '#type' => 'checkbox',
        '#title' => t('Display an absolute URL'),
        '#default_value' => $settings['absolute'],
      );
      break;
  }
  return $element;
}