You are here

public static function YamlFormSubmissionForm::hiddenElementValidate in YAML Form 8

Form element #element_validate callback: Execute #element_validate and suppress errors.

File

src/YamlFormSubmissionForm.php, line 1190

Class

YamlFormSubmissionForm
Provides a form to collect and edit submissions.

Namespace

Drupal\yamlform

Code

public static function hiddenElementValidate(array $element, FormStateInterface $form_state) {

  // Create a temp form state that will capture and suppress all element
  // validation errors.
  $temp_form_state = clone $form_state;
  $temp_form_state
    ->setLimitValidationErrors([]);

  // @see \Drupal\Core\Form\FormValidator::doValidateForm
  foreach ($element['#_element_validate'] as $callback) {
    $complete_form =& $form_state
      ->getCompleteForm();
    call_user_func_array($form_state
      ->prepareCallback($callback), [
      &$element,
      &$temp_form_state,
      &$complete_form,
    ]);
  }

  // Get the temp form state's values.
  $form_state
    ->setValues($temp_form_state
    ->getValues());
}