You are here

public function SimplesitemapSettingsForm::validateForm in Simple XML sitemap 8

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/SimplesitemapSettingsForm.php, line 81
Contains \Drupal\simplesitemap\Form\SimplesitemapSettingsForm.

Class

SimplesitemapSettingsForm
SimplesitemapSettingsFrom

Namespace

Drupal\simplesitemap\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $max_links = $form_state
    ->getValue('max_links');
  if ($max_links != '') {
    if (!is_numeric($max_links) || $max_links < 1 || $max_links != round($max_links)) {
      $form_state
        ->setErrorByName('', t("The value of the max links field must be a positive integer and greater than 1."));
    }
  }
}