You are here

private static function BaseSettings::processConfigForm in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x src/Element/BaseSettings.php \Drupal\charts\Element\BaseSettings::processConfigForm()

Process config form.

Parameters

array $element: The current element.

array $options: Options.

Return value

array The element.

1 call to BaseSettings::processConfigForm()
BaseSettings::processSettings in src/Element/BaseSettings.php
Processes the settings element.

File

src/Element/BaseSettings.php, line 931

Class

BaseSettings
Provides a form element for setting a chart.

Namespace

Drupal\charts\Element

Code

private static function processConfigForm(array $element, array $options) {
  $tab_group = implode('][', array_merge($element['#parents'], [
    'defaults',
  ]));
  $display_parents = array_merge($element['#parents'], [
    'display',
  ]);
  $element['defaults'] = [
    '#type' => 'vertical_tabs',
    '#default_tab' => 'edit-' . implode('-', $display_parents),
  ];
  $element['display']['#type'] = 'details';
  $element['display']['#weight'] = 1;
  $element['display']['#group'] = $tab_group;
  $element['xaxis']['#type'] = 'details';
  $element['xaxis']['#weight'] = 2;
  $element['xaxis']['#group'] = $tab_group;
  $element['yaxis']['#type'] = 'details';
  $element['yaxis']['#weight'] = 3;
  $element['yaxis']['#group'] = $tab_group;
  $element['display']['colors'] = [
    '#title' => new TranslatableMarkup('Chart colors'),
    '#theme_wrappers' => [
      'form_element',
    ],
    '#prefix' => '<div class="chart-colors">',
    '#suffix' => '</div>',
  ];
  for ($color_count = 0; $color_count < 10; $color_count++) {
    $element['display']['colors'][$color_count] = [
      '#type' => 'textfield',
      '#attributes' => [
        'TYPE' => 'color',
      ],
      '#size' => 10,
      '#maxlength' => 7,
      '#theme_wrappers' => [],
      '#suffix' => ' ',
      '#default_value' => $options['display']['colors'][$color_count] ?? '',
    ];
  }
  return $element;
}