public function Field::buildOptionsForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field::buildOptionsForm()
Default options form that provides the label widget that all fields should have.
Overrides FieldPluginBase::buildOptionsForm
1 call to Field::buildOptionsForm()
- TermName::buildOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php - Default options form that provides the label widget that all fields should have.
1 method overrides Field::buildOptionsForm()
- TermName::buildOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TermName.php - Default options form that provides the label widget that all fields should have.
File
- core/
modules/ views/ src/ Plugin/ views/ field/ Field.php, line 416 - Contains \Drupal\views\Plugin\views\field\Field.
Class
- Field
- A field that displays entity field data.
Namespace
Drupal\views\Plugin\views\fieldCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$field = $this
->getFieldDefinition();
$formatters = $this->formatterPluginManager
->getOptions($field
->getType());
$column_names = array_keys($field
->getColumns());
// 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
->getColumns()) == 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' => $this
->t('Column used for click sorting'),
'#options' => array_combine($column_names, $column_names),
'#default_value' => $this->options['click_sort_column'],
'#description' => $this
->t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
);
}
$form['type'] = array(
'#type' => 'select',
'#title' => $this
->t('Formatter'),
'#options' => $formatters,
'#default_value' => $this->options['type'],
'#ajax' => array(
'url' => views_ui_build_form_url($form_state),
),
'#submit' => array(
array(
$this,
'submitTemporaryForm',
),
),
'#executes_submit_callback' => TRUE,
);
$form['field_api_classes'] = array(
'#title' => $this
->t('Use field template'),
'#type' => 'checkbox',
'#default_value' => $this->options['field_api_classes'],
'#description' => $this
->t('If checked, field api classes will be added by field templates. 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'] .= ' ' . $this
->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'];
$settings = $this->options['settings'] + $this->formatterPluginManager
->getDefaultSettings($format);
$options = array(
'field_definition' => $field,
'configuration' => array(
'type' => $format,
'settings' => $settings,
'label' => '',
'weight' => 0,
),
'view_mode' => '_custom',
);
// Get the settings form.
$settings_form = array(
'#value' => array(),
);
if ($formatter = $this->formatterPluginManager
->getInstance($options)) {
$settings_form = $formatter
->settingsForm($form, $form_state);
// Convert field UI selector states to work in the Views field form.
FormHelper::rewriteStatesSelector($settings_form, "fields[{$field->getName()}][settings_edit_form]", 'options');
}
$form['settings'] = $settings_form;
}