You are here

public function MediaLibrarySelectForm::viewsFormValidate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php \Drupal\media_library\Plugin\views\field\MediaLibrarySelectForm::viewsFormValidate()

File

core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php, line 139

Class

MediaLibrarySelectForm
Defines a field that outputs a checkbox and form for selecting media.

Namespace

Drupal\media_library\Plugin\views\field

Code

public function viewsFormValidate(array &$form, FormStateInterface $form_state) {
  $selected = array_filter($form_state
    ->getValue($this->options['id']));
  if (empty($selected)) {
    $form_state
      ->setErrorByName('', $this
      ->t('No items selected.'));
  }
}