Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Page.php

function Page::validateOptionsForm

Overrides PathPluginBase::validateOptionsForm

File

core/modules/views/src/Plugin/views/display/Page.php, line 494

Class

Page
The plugin that handles a full page.

Namespace

Drupal\views\Plugin\views\display

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
    parent::validateOptionsForm($form, $form_state);
    if ($form_state->get('section') == 'menu') {
        $path = $this->getOption('path');
        $menu_type = $form_state->getValue([
            'menu',
            'type',
        ]);
        if ($menu_type == 'normal' && str_contains($path, '%')) {
            $form_state->setError($form['menu']['type'], $this->t('Views cannot create normal menu links for paths with a % in them.'));
        }
        if ($menu_type == 'default tab' || $menu_type == 'tab') {
            $bits = explode('/', $path);
            $last = array_pop($bits);
            if ($last == '%') {
                $form_state->setError($form['menu']['type'], $this->t('A display whose path ends with a % cannot be a tab.'));
            }
        }
        if ($menu_type != 'none' && $form_state->isValueEmpty([
            'menu',
            'title',
        ])) {
            $form_state->setError($form['menu']['title'], $this->t('Title is required for this menu type.'));
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal