You are here

public function ClassesForm::submitForm in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/ClassesForm.php \Drupal\ds\Form\ClassesForm::submitForm()
  2. 8.2 src/Form/ClassesForm.php \Drupal\ds\Form\ClassesForm::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/ClassesForm.php, line 46

Class

ClassesForm
Configures classes used by wrappers and regions.

Namespace

Drupal\ds\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);

  // Prepare region classes.
  $region_classes = [];
  $regions = $form_state
    ->getValue('regions');
  if (!empty($regions)) {
    $region_classes = explode("\n", str_replace("\r", '', $form_state
      ->getValue('regions')));
  }

  // Prepare field classes.
  $field_classes = [];
  $fields = $form_state
    ->getValue('fields');
  if (!empty($fields)) {
    $field_classes = explode("\n", str_replace("\r", '', $form_state
      ->getValue('fields')));
  }
  $config = $this
    ->config('ds.settings');
  $config
    ->set('classes.region', $region_classes)
    ->set('classes.field', $field_classes)
    ->save();
}