function chado_views_handler_field::options_form

3.x chado_views_handler_field.inc chado_views_handler_field::options_form(&$form, &$form_state)
1.x chado_views_handler_field.inc chado_views_handler_field::options_form(&$form, &$form_state)

Provide options for views ui admin specific to fields.

File

tripal_chado/views_handlers/chado_views_handler_field.inc, line 136

Class

chado_views_handler_field
Views Field Handler for chado fields. Uses the same approach as the field api views_handler_field_field.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  $field = field_info_field($this->definition['field_name']);
  $formatters = _field_view_formatter_options($field['type']);

  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Formatter'),
    '#options' => $formatters,
    '#default_value' => $this->options['type'],
    '#ajax' => array(
      'path' => views_ui_build_form_url($form_state),
    ),
    '#submit' => array('views_ui_config_item_form_submit_temporary'),
    '#executes_submit_callback' => TRUE,
  );

  // Get the currently selected formatter.
  $format = $this->options['type'];

  $formatter = field_info_formatter_types($format);
  if (!isset($this->options['settings'])) {
    $this->options['settings'] = array();
  }
  $settings = $this->options['settings'] + field_info_formatter_settings($format);

  // Provide an instance array for hook_field_formatter_settings_form().
  ctools_include('fields');
  $this->instance = ctools_fields_fake_field_instance($this->definition['field_name'], '_custom', $formatter, $settings);

  // Store the settings in a '_custom' view mode.
  $this->instance['display']['_custom'] = array(
    'type' => $format,
    'settings' => $settings,
  );

  // Get the settings form.
  $settings_form = array('#value' => array());
  $function = $formatter['module'] . '_field_formatter_settings_form';
  if (function_exists($function)) {
    $settings_form = $function($field, $this->instance, '_custom', $form, $form_state);
  }
  $form['settings'] = $settings_form;
}