You are here

public function TestWebformHandler::validateForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php \Drupal\webform_test_handler\Plugin\WebformHandler\TestWebformHandler::validateForm()

Validate webform submission form.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Overrides WebformHandlerBase::validateForm

File

tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php, line 88

Class

TestWebformHandler
Webform submission test handler.

Namespace

Drupal\webform_test_handler\Plugin\WebformHandler

Code

public function validateForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
  $this
    ->displayMessage(__FUNCTION__);
  $value = $form_state
    ->getValue('element');
  if ($value && !in_array($value, [
    'access_allowed',
    'submission_access_denied',
    'element_access_denied',
  ])) {
    $form_state
      ->setErrorByName('element', $this
      ->t('The element must be empty. You entered %value.', [
      '%value' => $value,
    ]));
  }
}