You are here

public function SimplesitemapSettingsForm::validateForm in Simple XML sitemap 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/SimplesitemapSettingsForm.php \Drupal\simple_sitemap\Form\SimplesitemapSettingsForm::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/SimplesitemapSettingsForm.php, line 156

Class

SimplesitemapSettingsForm
Class SimplesitemapSettingsForm @package Drupal\simple_sitemap\Form

Namespace

Drupal\simple_sitemap\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $base_url = $form_state
    ->getValue('base_url');
  $form_state
    ->setValue('base_url', rtrim($base_url, '/'));
  if ($base_url !== '' && !UrlHelper::isValid($base_url, TRUE)) {
    $form_state
      ->setErrorByName('base_url', t('The base URL is invalid.'));
  }
}