You are here

public function WebformSubmissionConditionsValidator::submitForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::submitForm()

Submit form #states for visible elements.

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 WebformSubmissionConditionsValidatorInterface::submitForm

See also

\Drupal\webform\WebformSubmissionForm::submitForm

File

src/WebformSubmissionConditionsValidator.php, line 392

Class

WebformSubmissionConditionsValidator
Webform submission conditions (#states) validator.

Namespace

Drupal\webform

Code

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

  /** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
  $webform_submission = $form_state
    ->getFormObject()
    ->getEntity();

  // Check if we are in the middle of multiple wizard form and determine
  // if element access should be checked.
  $current_page = $form_state
    ->get('current_page');
  $check_access = !$current_page || $current_page === WebformInterface::PAGE_CONFIRMATION ? FALSE : TRUE;

  // Get submission data.
  $data = $webform_submission
    ->getData();

  // Recursive through the form and unset unset submission data for
  // form elements that are hidden.
  $this
    ->submitFormRecursive($form, $webform_submission, $data, $check_access);

  // Set submission data.
  $webform_submission
    ->setData($data);
}