You are here

public function ShareMessageSettingsForm::validateForm in Share Message 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/ShareMessageSettingsForm.php, line 70

Class

ShareMessageSettingsForm
Defines a form that configures Share Message global settings.

Namespace

Drupal\sharemessage\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  if ($form_state
    ->getValue('add_twitter_card') && empty($form_state
    ->getValue('twitter_user'))) {
    $form_state
      ->setErrorByName('twitter_user', t('Please enter your twitter account username in order to activate meta tags for twitter cards.'));
  }
}