You are here

public function ExposedChartType::buildExposedForm in Charts 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/field/ExposedChartType.php \Drupal\charts\Plugin\views\field\ExposedChartType::buildExposedForm()
  2. 5.0.x src/Plugin/views/field/ExposedChartType.php \Drupal\charts\Plugin\views\field\ExposedChartType::buildExposedForm()

Render our chunk of the exposed handler form when selecting

Overrides HandlerBase::buildExposedForm

File

src/Plugin/views/field/ExposedChartType.php, line 42

Class

ExposedChartType
Provides a Views handler that exposes a Chart Type field.

Namespace

Drupal\charts\Plugin\views\field

Code

public function buildExposedForm(&$form, FormStateInterface $form_state) {
  $label = $this->options['label'] ? $this->options['label'] : 'Chart Type';
  $selected_options = $this->options['chart_types'];
  $all_fields = $this->chartsTypes
    ->getChartTypes();
  $options = array_filter($all_fields, function ($key) use ($selected_options) {
    return in_array($key, $selected_options, TRUE);
  }, ARRAY_FILTER_USE_KEY);
  $form['ct'] = [
    '#title' => $this
      ->t('@value', [
      '@value' => $label,
    ]),
    '#type' => $this->options['exposed_select_type'],
    '#options' => $options,
    '#weight' => -20,
  ];
  if ($this->options['exposed_select_type'] == 'radios') {
    $form['ct']['#attributes']['class'] = [
      'chart-type-radios',
      'container-inline',
    ];
  }
  $form['ect'] = [
    '#type' => 'hidden',
    '#default_value' => 1,
  ];
}