You are here

public function WebformUiElementTestForm::submitForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_ui/src/Form/WebformUiElementTestForm.php \Drupal\webform_ui\Form\WebformUiElementTestForm::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 WebformUiElementFormBase::submitForm

File

modules/webform_ui/src/Form/WebformUiElementTestForm.php, line 180

Class

WebformUiElementTestForm
Provides a test webform for webform elements.

Namespace

Drupal\webform_ui\Form

Code

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

  // Rebuild is throwing the below error.
  // LogicException: Settings can not be serialized.
  // $form_state->setRebuild();
  // @todo Determine what object is being serialized with webform
  //
  // The webform element configuration is stored in the 'properties' key in
  // the webform, pass that through for submission.
  $element_form_state = clone $form_state;
  $element_form_state
    ->setValues($form_state
    ->getValue('properties'));
  $properties = $this
    ->getWebformElementPlugin()
    ->getConfigurationFormProperties($form, $element_form_state);

  // Set #default_value using 'test' element value.
  if ($element_value = $form_state
    ->getValue('element')) {
    $properties['#default_value'] = $element_value;
  }
  \Drupal::request()
    ->getSession()
    ->set('webform_ui_test_element_' . $this->type, $properties);
  $this
    ->messenger()
    ->addStatus($this
    ->t('Webform element %type test has been updated.', [
    '%type' => $this->type,
  ]));
}