You are here

public function ShariffSettingsForm::submitForm in Shariff Social Media Buttons 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/ShariffSettingsForm.php, line 25

Class

ShariffSettingsForm
Provides a settings form for the Shariff sharing buttons.

Namespace

Drupal\shariff\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('shariff.settings');
  $ignoreArray = [
    'actions',
    'form_build_id',
    'form_token',
    'form_id',
  ];
  foreach (Element::children($form) as $variable) {
    $value = $form_state
      ->getValue($form[$variable]['#parents']);
    if ($variable == 'shariff_services') {
      $value = array_filter($value);
    }
    if (!in_array($variable, $ignoreArray)) {
      $config
        ->set($variable, $value);
    }
  }
  $config
    ->save();
  if (method_exists($this, '_submitForm')) {
    $this
      ->_submitForm($form, $form_state);
  }
  parent::submitForm($form, $form_state);
}