You are here

public function NotificationsWidgetLoggerSettingsForm::validateForm in Notifications widget 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/NotificationsWidgetLoggerSettingsForm.php, line 112

Class

NotificationsWidgetLoggerSettingsForm
Provides settings for Activity tracking module.

Namespace

Drupal\notifications_widget\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $haystack = [
    'user',
    'node_type',
    'comment_type',
    'taxonomy_vocabulary',
  ];
  $values = $form_state
    ->getValues();
  $entities = explode(',', $values['additional_entity_type']);
  if (count(array_intersect($haystack, $entities)) > 0) {
    $form_state
      ->setErrorByName('additional_entity_type', $this
      ->t('Default entity type already exists.'));
  }
}