You are here

public function ScopeForm::validateForm in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x src/Form/ScopeForm.php \Drupal\oauth2_server\Form\ScopeForm::validateForm()

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/ScopeForm.php, line 102

Class

ScopeForm
Class Scope Form.

Namespace

Drupal\oauth2_server\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  if ($this->entity
    ->isNew() || $this->entity
    ->getOriginalId() != $this->entity
    ->id()) {
    $exists = $this->storage
      ->load($this->entity
      ->id());
    if ($exists) {
      $form_state
        ->setErrorByName('scope_id', $this
        ->t('This Scope ID already exists.'));
    }
  }
}