You are here

public function Select2BoxesConfigForm::submitForm in Select2 Boxes 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/Select2BoxesConfigForm.php, line 123

Class

Select2BoxesConfigForm
Class Select2BoxesConfigForm.

Namespace

Drupal\select2boxes\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $fields = [
    'limited_search',
    'select2_global',
    'disable_for_admin_pages',
    'minimum_search_length',
    'provider',
    'version',
    'url',
  ];
  $editable = $this->configFactory
    ->getEditable($this
    ->getEditableConfigNames()[0]);
  foreach ($fields as $value) {
    if ($form_state
      ->hasValue($value)) {
      $editable
        ->set($value, $form_state
        ->getValue($value));
    }
  }
  $editable
    ->save();
  parent::submitForm($form, $form_state);
}