You are here

public function LanguageMappingAddForm::validateForm in Flags 8

@inheritDoc

Overrides FormBase::validateForm

File

flags_ui/src/Form/LanguageMappingAddForm.php, line 40

Class

LanguageMappingAddForm
Class FlagMappingAddForm.

Namespace

Drupal\flags_ui\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Check if config entity that's being created already exists.
  $id = 'flags.language_flag_mapping.' . $form_state
    ->getValue('source');
  if (!$this
    ->config($id)
    ->isNew()) {
    $form_state
      ->setErrorByName('source', $this
      ->t('Mapping for this language already exists.'));
  }
}