You are here

public function WebformVariantApplyForm::validateForm in Webform 6.x

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

Form validation handler.

Parameters

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

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

Overrides FormBase::validateForm

File

src/Form/WebformVariantApplyForm.php, line 193

Class

WebformVariantApplyForm
Form for apply a webform variant.

Namespace

Drupal\webform\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $variants = array_filter($form_state
    ->getValue('variants') ?: []);
  if ($this->hasMultipleVariants && empty($variants)) {
    $form_state
      ->setErrorByName('variants', $this
      ->t('Please select variants to be applied to the webform.'));
  }
}