You are here

public static function WebformSubmissionViewsReplace::validateWebformSubmissionViewsReplace in Webform 8.5

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

Validates webform submission views replacement element.

File

src/Element/WebformSubmissionViewsReplace.php, line 124

Class

WebformSubmissionViewsReplace
Provides a form element for selecting webform submission views replacement routes.

Namespace

Drupal\webform\Element

Code

public static function validateWebformSubmissionViewsReplace(&$element, FormStateInterface $form_state, &$complete_form) {
  $values = NestedArray::getValue($form_state
    ->getValues(), $element['#parents']);

  // Remove empty view replace references.
  if (empty($values['global_routes']) && empty($values['webform_routes']) && empty($values['node_routes'])) {
    $values = [];
  }
  $element['#value'] = $values;
  $form_state
    ->setValueForElement($element, $values);
}