You are here

public function GridStackSettingsForm::submitForm in GridStack 8

Same name and namespace in other branches
  1. 8.2 modules/gridstack_ui/src/Form/GridStackSettingsForm.php \Drupal\gridstack_ui\Form\GridStackSettingsForm::submitForm()

Implements \Drupal\Core\Form\FormInterface::submitForm().

Overrides ConfigFormBase::submitForm

File

modules/gridstack_ui/src/Form/GridStackSettingsForm.php, line 105

Class

GridStackSettingsForm
Defines the GridStack admin settings form.

Namespace

Drupal\gridstack_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable('gridstack.settings');
  foreach ([
    'customized',
    'framework',
    'library',
  ] as $key) {
    $config
      ->set($key, $form_state
      ->getValue($key));
  }
  $config
    ->save();

  // Invalidate the library discovery cache to update new assets.
  $this->libraryDiscovery
    ->clearCachedDefinitions();

  // If anything fails, notice to clear the cache.
  $this->messenger
    ->addMessage($this
    ->t('Be sure to <a href=":clear_cache">clear the cache</a> <strong>ONLY IF</strong> trouble to see the updated libraries.', [
    ':clear_cache' => Url::fromRoute('system.performance_settings')
      ->toString(),
  ]));
  parent::submitForm($form, $form_state);
}