You are here

public function ScatterField::buildOptionsForm in Charts 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/field/ScatterField.php \Drupal\charts\Plugin\views\field\ScatterField::buildOptionsForm()
  2. 8.3 src/Plugin/views/field/ScatterField.php \Drupal\charts\Plugin\views\field\ScatterField::buildOptionsForm()

Default options form that provides the label widget that all fields should have.

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/ScatterField.php, line 46
Defines Drupal\charts\Plugin\views\field\ScatterField.

Class

ScatterField
Field handler to provide x and y values for a scatter plot.

Namespace

Drupal\charts\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $fieldList = $this->displayHandler
    ->getFieldLabels();
  unset($fieldList['field_charts_fields_scatter']);
  $form['fieldset_one'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Select the field representing the X axis.'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#weight' => -10,
    '#required' => TRUE,
  ];
  $form['fieldset_one']['x_axis'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('X Axis Field'),
    '#options' => $fieldList,
    '#default_value' => $this->options['fieldset_one']['x_axis'],
    '#weight' => -10,
  ];
  $form['fieldset_two'] = [
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => $this
      ->t('Select the field representing the Y axis.'),
    '#weight' => -9,
    '#required' => TRUE,
  ];
  $form['fieldset_two']['y_axis'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Y Axis Field'),
    '#options' => $fieldList,
    '#default_value' => $this->options['fieldset_two']['y_axis'],
    '#weight' => -9,
  ];
  return $form;
}