You are here

public function ChosenConfigForm::submitForm in Chosen 8.2

Same name and namespace in other branches
  1. 3.0.x src/Form/ChosenConfigForm.php \Drupal\chosen\Form\ChosenConfigForm::submitForm()

Chosen configuration form submit handler.

Validates submission by checking for duplicate entries, invalid characters, and that there is an abbreviation and phrase pair.

Overrides ConfigFormBase::submitForm

File

src/Form/ChosenConfigForm.php, line 236

Class

ChosenConfigForm
Implements a ChosenConfig form.

Namespace

Drupal\chosen\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable('chosen.settings');
  $config
    ->set('minimum_single', $form_state
    ->getValue('minimum_single'))
    ->set('minimum_multiple', $form_state
    ->getValue('minimum_multiple'))
    ->set('disable_search_threshold', $form_state
    ->getValue('disable_search_threshold'))
    ->set('max_shown_results', $form_state
    ->getValue('max_shown_results'))
    ->set('minimum_width', $form_state
    ->getValue('minimum_width'))
    ->set('use_relative_width', $form_state
    ->getValue('use_relative_width'))
    ->set('jquery_selector', $form_state
    ->getValue('jquery_selector'))
    ->set('search_contains', $form_state
    ->getValue('search_contains'))
    ->set('disable_search', $form_state
    ->getValue('disable_search'))
    ->set('allow_single_deselect', $form_state
    ->getValue('allow_single_deselect'))
    ->set('disabled_themes', $form_state
    ->getValue('disabled_themes'))
    ->set('chosen_include', $form_state
    ->getValue('chosen_include'))
    ->set('placeholder_text_multiple', $form_state
    ->getValue('placeholder_text_multiple'))
    ->set('placeholder_text_single', $form_state
    ->getValue('placeholder_text_single'))
    ->set('no_results_text', $form_state
    ->getValue('no_results_text'));
  $config
    ->save();
  parent::submitForm($form, $form_state);
}