public function WebformVariantApplyForm::validateForm in Webform 8.5
Same name and namespace in other branches
- 6.x 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\FormCode
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.'));
}
}