You are here

public function ExampleWebformHandler::validateForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php \Drupal\webform_example_handler\Plugin\WebformHandler\ExampleWebformHandler::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

modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php, line 119

Class

ExampleWebformHandler
Webform example handler.

Namespace

Drupal\webform_example_handler\Plugin\WebformHandler

Code

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