You are here

public function AutoUsernameSettingsForm::submitForm in Automatic User Names 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/AutoUsernameSettingsForm.php, line 281

Class

AutoUsernameSettingsForm
Class AutoUsernameSettingsForm.

Namespace

Drupal\auto_username\Form

Code

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

  // Set values in variables.
  $config
    ->set('aun_pattern', $form_state
    ->getValues()['aun_pattern']);
  $config
    ->set('aun_php', $form_state
    ->getValues()['aun_php']);
  $config
    ->set('aun_update_on_edit', $form_state
    ->getValues()['aun_update_on_edit']);
  $config
    ->set('aun_separator', $form_state
    ->getValues()['aun_separator']);
  $config
    ->set('aun_case', $form_state
    ->getValues()['aun_case']);
  $config
    ->set('aun_max_length', $form_state
    ->getValues()['aun_max_length']);
  $config
    ->set('aun_max_component_length', $form_state
    ->getValues()['aun_max_component_length']);
  $config
    ->set('aun_transliterate', $form_state
    ->getValues()['aun_transliterate']);
  $config
    ->set('aun_reduce_ascii', $form_state
    ->getValues()['aun_reduce_ascii']);
  $config
    ->set('aun_replace_whitespace', $form_state
    ->getValues()['aun_replace_whitespace']);
  $config
    ->set('aun_ignore_words', $form_state
    ->getValues()['aun_ignore_words']);
  $punctuation = $this
    ->autoUsernamePunctuationChars();
  foreach ($punctuation as $name => $details) {
    $config
      ->set('aun_punctuation_' . $name, $form_state
      ->getValues()['aun_punctuation_' . $name]);
  }
  $config
    ->save();
}