You are here

public function FontDisplayForm::validateForm in @font-your-face 8.3

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/FontDisplayForm.php, line 149

Class

FontDisplayForm
Form to display fonts.

Namespace

Drupal\fontyourface\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $preset_selectors = $form_state
    ->getValue('preset_selectors');
  $selectors = $form_state
    ->getValue('selectors');
  if ($preset_selectors == 'other' && empty($selectors)) {
    $form_state
      ->setError($form['selectors'], $this
      ->t("A selector is required if 'other' preset selector is selected"));
  }
}