You are here

public function SettingsForm::validateForm in Simple XML sitemap 4.x

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/SettingsForm.php, line 206

Class

SettingsForm
Class SettingsForm

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', $this
      ->t('The base URL is invalid.'));
  }
}