function views_handler_field_field::option_definition

Overrides views_handler_field::option_definition

File

modules/field/views_handler_field_field.inc, line 340

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

public 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['delta_random'] = 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;
}