You are here

public function JavascriptLibrariesEditForm::validateForm in JavaScript Libraries Manager 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/JavascriptLibrariesEditForm.php, line 128
Contains \Drupal\javascript_libraries\Form\JavascriptLibrariesEditForm.

Class

JavascriptLibrariesEditForm

Namespace

Drupal\javascript_libraries\Form

Code

public function validateForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  switch ($form_state
    ->getValue([
    'library_type',
  ])) {
    case 'external':
      _javascript_libraries_url_validate($form, $form_state);
      break;
    case 'file':
      _javascript_libraries_file_validate($form, $form_state);
      break;
  }

  // Trim the name/description:
  $form_state
    ->setValue([
    'name',
  ], trim($form_state
    ->getValue([
    'name',
  ])));
}