You are here

public function MergeTermsTarget::validateForm in Term Merge 8

Plugin annotation

@SuppressWarnings(camelCase);

Overrides FormBase::validateForm

File

src/Form/MergeTermsTarget.php, line 128

Class

MergeTermsTarget
Term merge target terms form.

Namespace

Drupal\term_merge\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $new = !empty($form_state
    ->getValue('new'));
  $existing = !empty($form_state
    ->getValue('existing'));
  if ($new !== $existing) {
    return;
  }
  $form_state
    ->setErrorByName('new', $this
    ->t('You must either select an existing term or enter a new term.'));
}