1 views_handler_field_field.inc | views_handler_field_field::options_form(&$form, &$form_state) |
Default options form that provides the label widget that all fields should have.
Overrides views_handler_field::options_form
File
- core/
modules/ field/ views/ views_handler_field_field.inc, line 401 - Definition of views_handler_field_field.
Class
- views_handler_field_field
- A field that displays fieldapi fields.
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$field = $this->field_info;
$formatters = _field_view_formatter_options($field['type']);
$column_names = array_keys($field['columns']);
// If this is a multiple value field, add its options.
if ($this->multiple) {
$this->multiple_options_form($form, $form_state);
}
// No need to ask the user anything if the field has only one column.
if (count($field['columns']) == 1) {
$form['click_sort_column'] = array(
'#type' => 'value',
'#value' => isset($column_names[0]) ? $column_names[0] : '',
);
}
else {
$form['click_sort_column'] = array(
'#type' => 'select',
'#title' => t('Column used for click sorting'),
'#options' => backdrop_map_assoc($column_names),
'#default_value' => $this->options['click_sort_column'],
'#description' => t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
'#fieldset' => 'more',
);
}
$form['type'] = array(
'#type' => 'select',
'#title' => t('Formatter'),
'#options' => $formatters,
'#default_value' => $this->options['type'],
'#ajax' => array(
'path' => views_ui_build_form_path($form_state),
),
'#submit' => array('views_ui_config_item_form_submit_temporary'),
'#executes_submit_callback' => TRUE,
);
$form['field_api_classes'] = array(
'#title' => t('Use field template'),
'#type' => 'checkbox',
'#default_value' => $this->options['field_api_classes'],
'#description' => t('If checked, field api classes will be added using field.tpl.php (or equivalent). This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
'#fieldset' => 'style_settings',
'#weight' => 20,
);
if ($this->multiple) {
$form['field_api_classes']['#description'] .= ' ' . t('Checking this option will cause the group Display Type and Separator values to be ignored.');
}
// Get the currently selected formatter.
$format = $this->options['type'];
$formatter = field_info_formatter_types($format);
$settings = $this->options['settings'] + field_info_formatter_settings($format);
// Provide an instance array for hook_field_formatter_settings_form().
$field = field_read_field($this->definition['field_name']);
$field_type = field_info_field_types($field['type']);
$this->instance = array(
// Build a fake entity type and bundle.
'field_name' => $this->definition['field_name'],
'entity_type' => 'views',
'bundle' => 'view',
// Use the default field settings for settings and widget.
'settings' => field_info_instance_settings($field['type']),
'widget' => array(
'type' => $field_type['default_widget'],
'settings' => array(),
),
// Build a dummy display mode.
'display' => array(
'_custom' => array(
'type' => $formatter,
'settings' => $settings,
),
),
// Set the other fields to their default values.
// @see _field_write_instance().
'required' => FALSE,
'label' => $field['field_name'],
'description' => '',
'deleted' => 0,
);
// Store the settings in a '_custom' display mode.
$this->instance['display']['_custom'] = array(
'type' => $format,
'settings' => $settings,
);
// Get the settings form.
$settings_form = array(
'#type' => 'value',
'#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;
}