You are here

public function ChartsConfigForm::submitForm in Charts 8.4

Same name and namespace in other branches
  1. 8 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::submitForm()
  2. 8.3 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::submitForm()
  3. 5.0.x src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/ChartsConfigForm.php, line 97

Class

ChartsConfigForm
Charts Config Form.

Namespace

Drupal\charts\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $settings = $form_state
    ->getValue('settings');

  // The settings form element is returning an unneeded 'defaults' value.
  if (isset($settings['defaults'])) {
    unset($settings['defaults']);
  }

  // Save the main settings.
  $this->config
    ->set('charts_default_settings', $settings);
  $this->config
    ->save();

  // Invalidate cache tags to refresh any view relying on this.
  $this->cacheTagsInvalidator
    ->invalidateTags($this->config
    ->getCacheTags());
  parent::submitForm($form, $form_state);
}