function EntityField::defineOptions
Same name in other branches
- 9 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::defineOptions()
- 8.9.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::defineOptions()
- 11.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::defineOptions()
Overrides FieldPluginBase::defineOptions
1 method overrides EntityField::defineOptions()
- TermName::defineOptions in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php - Information about options for all kinds of purposes will be held here.
File
-
core/
modules/ views/ src/ Plugin/ views/ field/ EntityField.php, line 406
Class
- EntityField
- A field that displays entity field data.
Namespace
Drupal\views\Plugin\views\fieldCode
protected function defineOptions() {
$options = parent::defineOptions();
$field_storage_definition = $this->getFieldStorageDefinition();
$field_type = $this->fieldTypePluginManager
->getDefinition($field_storage_definition->getType());
$column_names = array_keys($field_storage_definition->getColumns());
$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'] = [
'default' => $default_column,
];
if (isset($this->definition['default_formatter'])) {
$options['type'] = [
'default' => $this->definition['default_formatter'],
];
}
elseif (isset($field_type['default_formatter'])) {
$options['type'] = [
'default' => $field_type['default_formatter'],
];
}
else {
$options['type'] = [
'default' => '',
];
}
$options['settings'] = [
'default' => $this->definition['default_formatter_settings'] ?? [],
];
$options['group_column'] = [
'default' => $default_column,
];
$options['group_columns'] = [
'default' => [],
];
// Options used for multiple value fields.
$options['group_rows'] = [
'default' => TRUE,
];
// If we know the exact number of allowed values, then that can be
// the default. Otherwise, default to 'all'.
$options['delta_limit'] = [
'default' => $field_storage_definition->getCardinality() > 1 ? $field_storage_definition->getCardinality() : 0,
];
$options['delta_offset'] = [
'default' => 0,
];
$options['delta_reversed'] = [
'default' => FALSE,
];
$options['delta_first_last'] = [
'default' => FALSE,
];
$options['multi_type'] = [
'default' => 'separator',
];
$options['separator'] = [
'default' => ', ',
];
$options['field_api_classes'] = [
'default' => FALSE,
];
return $options;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.