You are here

public function LockrAdvancedForm::submitForm in Lockr 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::submitForm()
  2. 8.2 src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::submitForm()
  3. 4.x src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::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 FormInterface::submitForm

File

src/Form/LockrAdvancedForm.php, line 151

Class

LockrAdvancedForm
Form handler for advanced Lockr settings.

Namespace

Drupal\lockr\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $custom = $form_state
    ->getValue('custom');
  $region = $form_state
    ->getValue('region');
  $config = $this->configFactory
    ->getEditable('lockr.settings');
  if ($region) {
    $config
      ->set('region', $region);
  }
  else {
    $config
      ->clear('region');
  }
  $config
    ->set('custom', $custom);
  if ($custom) {
    $config
      ->set('cert_path', $form_state
      ->getValue('custom_cert'));
  }
  else {
    $config
      ->clear('custom_cert');
  }
  $config
    ->save();
}