You are here

public function SlickSettingsForm::submitForm in Slick Carousel 7.3

Same name and namespace in other branches
  1. 8.2 slick_ui/src/Form/SlickSettingsForm.php \Drupal\slick_ui\Form\SlickSettingsForm::submitForm()
  2. 8 slick_ui/src/Form/SlickSettingsForm.php \Drupal\slick_ui\Form\SlickSettingsForm::submitForm()

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

File

slick_ui/src/Form/SlickSettingsForm.php, line 76

Class

SlickSettingsForm
Defines the Slick admin settings form.

Namespace

Drupal\slick_ui\Form

Code

public function submitForm($form, &$form_state) {
  $defaults = SlickDefault::formSettings();
  $data = [];

  // Always run typecasting on submit.
  $this->manager
    ->typecast($form_state['values'], 'slick.settings', TRUE);
  foreach ($defaults as $key => $value) {
    if (isset($form_state['values'][$key])) {
      $data[$key] = $form_state['values'][$key];
    }
  }

  // Merge all flat variables into blazy.settings.
  variable_set('slick.settings', $data);

  // Safe to remove old array since already merged above.
  foreach ($defaults as $key => $value) {
    if (isset($form_state['values'][$key])) {
      unset($form_state['values'][$key]);
    }
  }
}