You are here

public function ExtraBodyClassesConfigForm::submitForm in Extra body classes 8

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/ExtraBodyClassesConfigForm.php, line 217

Class

ExtraBodyClassesConfigForm
Configure where you want to append "extra body classes".

Namespace

Drupal\extra_body_classes\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable('extra_body_classes.settings');

  // Current browser's platform.
  $config
    ->set('extra_body_classes_browser_platform', $form_state
    ->getValue('extra_body_classes_browser_platform'))
    ->save();

  // Name and version of browser.
  $config
    ->set('extra_body_classes_browser_name_version', $form_state
    ->getValue('extra_body_classes_browser_name_version'))
    ->save();

  // Check whether current device is desktop or mobile.
  $config
    ->set('extra_body_classes_browser_device', $form_state
    ->getValue('extra_body_classes_browser_device'))
    ->save();

  // Current date.
  $config
    ->set('extra_body_classes_date', $form_state
    ->getValue('extra_body_classes_date'))
    ->save();

  // Current year.
  $config
    ->set('extra_body_classes_year', $form_state
    ->getValue('extra_body_classes_year'))
    ->save();

  // Current month.
  $config
    ->set('extra_body_classes_month', $form_state
    ->getValue('extra_body_classes_month'))
    ->save();

  // Current day.
  $config
    ->set('extra_body_classes_day', $form_state
    ->getValue('extra_body_classes_day'))
    ->save();

  // Current role.
  $config
    ->set('extra_body_classes_roles', $form_state
    ->getValue('extra_body_classes_roles'))
    ->save();

  // Single day event.
  $config
    ->set('extra_body_classes_browser_single_day_event', $form_state
    ->getValue('extra_body_classes_browser_single_day_event'))
    ->save();
  $config
    ->set('extra_body_classes_browser_single_day_event_begins', $form_state
    ->getValue('extra_body_classes_browser_single_day_event_begins'))
    ->save();

  // Multiple day event.
  $config
    ->set('extra_body_classes_event', $form_state
    ->getValue('extra_body_classes_event'))
    ->save();
  $config
    ->set('extra_body_classes_event_start_date', $form_state
    ->getValue('extra_body_classes_event_start_date'))
    ->save();
  $config
    ->set('extra_body_classes_event_end_date', $form_state
    ->getValue('extra_body_classes_event_end_date'))
    ->save();

  // Custom classes.
  $config
    ->set('extra_body_classes_custom_classes', $form_state
    ->getValue('extra_body_classes_custom_classes'))
    ->save();
  $config
    ->set('extra_body_classes_custom_classes_path', $form_state
    ->getValue('extra_body_classes_custom_classes_path'))
    ->save();
  parent::submitForm($form, $form_state);
}