You are here

public function JwplayerSettingsForm::validateForm in JW Player 8

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/JwplayerSettingsForm.php, line 113

Class

JwplayerSettingsForm
Configure search settings for this site.

Namespace

Drupal\jw_player\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  switch ($form_state
    ->getValue('jw_player_hosting')) {
    case '':
      $form_state
        ->setErrorByName('jw_player_hosting', t('Hosting type is required.'));
      break;
    case 'self':
      if ($form_state
        ->getValue('jw_player_key') == "" && $form_state
        ->getValue('jw_player_version') >= '7') {
        $form_state
          ->setErrorByName('jw_player_key', t('Self-Hosted Player License Key is required when Hosting type is "Self-Hosted".'));
      }
      break;
    case 'cloud':
      if ($form_state
        ->getValue('cloud_player_library_url') == "") {
        $form_state
          ->setErrorByName('cloud_player_library_url', t('Default Cloud Player Url is required when Hosting type is "Cloud-Hosted".'));
      }
      break;
  }
}