You are here

public function WebformAdminConfigElementsForm::submitForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/AdminConfig/WebformAdminConfigElementsForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigElementsForm::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 WebformAdminConfigBaseForm::submitForm

File

src/Form/AdminConfig/WebformAdminConfigElementsForm.php, line 533

Class

WebformAdminConfigElementsForm
Configure webform admin settings for elements.

Namespace

Drupal\webform\Form\AdminConfig

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Format.
  $format = $form_state
    ->getValue('format');
  foreach ($format as $element_id => $element_format) {
    $format[$element_id] = array_filter($element_format);
  }
  $format = array_filter($format);

  // Excluded elements.
  $excluded_elements = $this
    ->convertIncludedToExcludedPluginIds($this->elementManager, $form_state
    ->getValue('excluded_elements'));

  // Update config and submit form.
  $config = $this
    ->config('webform.settings');
  $config
    ->set('element', $form_state
    ->getValue('element') + $form_state
    ->getValue('location') + $form_state
    ->getValue('select') + [
    'excluded_elements' => $excluded_elements,
  ]);
  $config
    ->set('html_editor', $form_state
    ->getValue('html_editor'));
  $file = $form_state
    ->getValue('file');
  $config
    ->set('settings.default_form_file_limit', $file['default_form_file_limit']);
  unset($file['default_form_file_limit']);
  $config
    ->set('file', $file);
  $config
    ->set('format', $format);
  parent::submitForm($form, $form_state);

  // Reset libraries cached.
  // @see webform_library_info_build()
  \Drupal::service('library.discovery')
    ->clearCachedDefinitions();
}