You are here

public function DisplayTest::validateOptionsForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php \Drupal\views_test_data\Plugin\views\display\DisplayTest::validateOptionsForm()

Validate the options form.

Overrides DisplayPluginBase::validateOptionsForm

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php, line 92

Class

DisplayTest
Defines a Display test plugin.

Namespace

Drupal\views_test_data\Plugin\views\display

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  parent::validateOptionsForm($form, $form_state);
  \Drupal::logger('views')
    ->notice($form_state
    ->getValue('test_option'));
  switch ($form_state
    ->get('section')) {
    case 'test_option':
      if (!trim($form_state
        ->getValue('test_option'))) {
        $form_state
          ->setError($form['test_option'], $this
          ->t('You cannot have an empty option.'));
      }
      break;
  }
}