You are here

public function PickAccountsForm::validateForm in User Merge 2.x

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/PickAccountsForm.php, line 131

Class

PickAccountsForm
Class PickAccountsForm.

Namespace

Drupal\usermerge\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $retire = $form_state
    ->getValue('retire');
  $retain = $form_state
    ->getValue('retain');
  if ($retire == 1) {
    $form_state
      ->setErrorByName('retire', $this
      ->t("Retiring user 1 is not allowed."));
  }
  if ($retire == $retain) {
    $form_state
      ->setErrorByName('retain', $this
      ->t("You must pick a different account from the one you're retiring."));
  }
}