function views_handler_field_field::option_definition

3.x views_handler_field_field.inc views_handler_field_field::option_definition()

Information about options for all kinds of purposes will be held here. @code 'option_name' => array(

  • 'default' => default value,
  • 'translatable' => (optional) TRUE/FALSE (wrap in t() on export if true),
  • 'contains' => (optional) array of items this contains, with its own defaults, etc. If contains is set, the default will be ignored and assumed to be array().
  • 'bool' => (optional) TRUE/FALSE Is the value a boolean value. This will change the export format to TRUE/FALSE instead of 1/0.
  • 'export' => (optional) FALSE or a callback for special export handling if necessary.
  • 'unpack_translatable' => (optional) callback for special handling for translating data within the option, if necessary.

),

Return value

array Returns the options of this handler/plugin.

Overrides views_handler_field::option_definition

See also

views_object::export_option()

views_object::export_option_always()

views_object::unpack_translatable()

File

modules/field/views_handler_field_field.inc, line 332
Definition of views_handler_field_field.

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

function option_definition() {
  $options = parent::option_definition();

  // option_definition runs before init/construct, so no $this->field_info
  $field = field_info_field($this->definition['field_name']);
  $field_type = field_info_field_types($field['type']);
  $column_names = array_keys($field['columns']);
  $default_column = '';
  // Try to determine a sensible default.
  if (count($column_names) == 1) {
    $default_column = $column_names[0];
  }
  elseif (in_array('value', $column_names)) {
    $default_column = 'value';
  }

  // If the field has a "value" column, we probably need that one.
  $options['click_sort_column'] = array(
    'default' => $default_column,
  );
  $options['type'] = array(
    'default' => $field_type['default_formatter'],
  );
  $options['settings'] = array(
    'default' => array(),
  );
  $options['group_column'] = array(
    'default' => $default_column,
  );
  $options['group_columns'] = array(
    'default' => array(),
  );

  // Options used for multiple value fields.
  $options['group_rows'] = array(
    'default' => TRUE,
    'bool' => TRUE,
  );
  // If we know the exact number of allowed values, then that can be
  // the default. Otherwise, default to 'all'.
  $options['delta_limit'] = array(
    'default' => ($field['cardinality'] > 1) ? $field['cardinality'] : 'all',
  );
  $options['delta_offset'] = array(
    'default' => 0,
  );
  $options['delta_reversed'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );
  $options['delta_first_last'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );

  $options['multi_type'] = array(
    'default' => 'separator'
  );
  $options['separator'] = array(
    'default' => ', '
  );

  $options['field_api_classes'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );

  return $options;
}