You are here

public function ShariffSettingsForm::validateForm in Shariff Social Media Buttons 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/ShariffSettingsForm.php, line 54

Class

ShariffSettingsForm
Provides a settings form for the Shariff sharing buttons.

Namespace

Drupal\shariff\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $backend_url = $form_state
    ->getValue('shariff_backend_url');
  if ($backend_url && !UrlHelper::isValid($backend_url, TRUE)) {
    $form_state
      ->setErrorByName('shariff_backend_url', $this
      ->t('Please enter a valid URL.'));
  }
}