You are here

public function EditTexts::submitForm in TacJS 8.5

Same name and namespace in other branches
  1. 8.6 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::submitForm()
  2. 8.2 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::submitForm()
  3. 8.3 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::submitForm()
  4. 8.4 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::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/Steps/EditTexts.php, line 406

Class

EditTexts
Class EditTexts.

Namespace

Drupal\tacjs\Form\Steps

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('tacjs.settings');
  $elements = [
    'middleBarHead',
    'adblock',
    'adblock_call',
    'reload',
    'alertBigScroll',
    'alertBigClick',
    'alertBig',
    'alertBigPrivacy',
    'alertSmall',
    'personalize',
    'acceptAll',
    'close',
    'privacyUrl',
    'all',
    'info',
    'disclaimer',
    'allow',
    'deny',
    'noCookie',
    'useCookie',
    'useCookieCurrent',
    'useNoCookie',
    'more',
    'source',
    'credit',
    'noServices',
    'toggleInfoBox',
    'title',
    'cookieDetail',
    'ourSite',
    'newWindow',
    'allowAll',
    'denyAll',
    'fallback',
    'ads_title',
    'ads_details',
    'analytic_title',
    'analytic_details',
    'social_title',
    'social_details',
    'video_title',
    'video_details',
    'comment_title',
    'comment_details',
    'support_title',
    'support_details',
    'api_title',
    'api_details',
    'other_title',
    'other_details',
    'mandatoryTitle',
    'mandatoryText',
  ];
  foreach ($elements as $key) {
    if ($form_state
      ->getValue($key)) {
      $config
        ->set('texts.' . $key, $form_state
        ->getValue($key));
    }
    else {
      $config
        ->clear('texts.' . $key);
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}