You are here

public function CountryMappingAddForm::validateForm in Flags 8

@inheritDoc

Overrides FormBase::validateForm

File

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

Class

CountryMappingAddForm
Class CountryMappingAddForm.

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.country_flag_mapping.' . strtolower($form_state
    ->getValue('source'));
  if (!$this
    ->config($id)
    ->isNew()) {
    $form_state
      ->setErrorByName('source', $this
      ->t('Mapping for this country already exists.'));
  }
}