You are here

public function MaskedInputSettingsForm::submitForm in Masked Input 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/MaskedInputSettingsForm.php, line 78

Class

MaskedInputSettingsForm
provides Configure settings.

Namespace

Drupal\masked_input

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_state_values = $form_state
    ->getValue([
    'definitions',
  ]);
  foreach ($form_state_values as $key => $value) {
    if (empty($value['character']) || empty($value['regex'])) {
      unset($form_state_values[$key]);
    }
  }
  $this
    ->config('masked_input.settings')
    ->set('masked_input_definitions', $form_state_values)
    ->save();
  parent::submitForm($form, $form_state);
}