You are here

public function WebformSubmissionDevelGenerateTrait::validateForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/DevelGenerate/WebformSubmissionDevelGenerateTrait.php \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerateTrait::validateForm()

Custom validation handler.

File

src/Plugin/DevelGenerate/WebformSubmissionDevelGenerateTrait.php, line 199

Class

WebformSubmissionDevelGenerateTrait
Provides a WebformSubmissionDevelGenerate plugin.

Namespace

Drupal\webform\Plugin\DevelGenerate

Code

public function validateForm(array $form, FormStateInterface $form_state) {
  $webform_ids = array_filter($form_state
    ->getValue('webform_ids'));

  // Let default webform validation handle requiring webform ids.
  if (empty($webform_ids)) {
    return;
  }
  $entity_type = $form_state
    ->getValue('entity-type');
  $entity_id = $form_state
    ->getValue('entity-id');
  if ($entity_type) {
    if ($error = $this
      ->validateEntity($webform_ids, $entity_type, $entity_id)) {
      $form_state
        ->setErrorByName('entity_type', $error);
    }
  }
}