You are here

public function BrightcoveSubscriptionForm::validateForm in Brightcove Video Connect 8.2

Same name and namespace in other branches
  1. 8 src/Form/BrightcoveSubscriptionForm.php \Drupal\brightcove\Form\BrightcoveSubscriptionForm::validateForm()
  2. 3.x src/Form/BrightcoveSubscriptionForm.php \Drupal\brightcove\Form\BrightcoveSubscriptionForm::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/BrightcoveSubscriptionForm.php, line 79

Class

BrightcoveSubscriptionForm
Builds the form for Brightcove Subscription add, edit.

Namespace

Drupal\brightcove\Form

Code

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

  // Validate endpoint, it should be unique.
  if (!empty(BrightcoveSubscription::loadByEndpoint($form_state
    ->getValue('endpoint')))) {
    $form_state
      ->setErrorByName('endpoint', $this
      ->t('A subscription with the %endpoint endpoint already exists.', [
      '%endpoint' => $form_state
        ->getValue('endpoint'),
    ]));
  }
}