/** * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::validateOptionsForm(). */ 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(array('menu', 'type')); if ($menu_type == 'normal' && strpos($path, '%') !== FALSE) { $form_state->setError($form['menu']['type'], $this->t('Views cannot create normal menu items 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(array('menu', 'title'))) { $form_state->setError($form['menu']['title'], $this->t('Title is required for this menu type.')); } } }
/** * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::validateOptionsForm(). */ public function validateOptionsForm(&$form, &$form_state) { parent::validateOptionsForm($form, $form_state); if ($form_state['section'] == 'menu') { $path = $this->getOption('path'); if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) { form_error($form['menu']['type'], $form_state, t('Views cannot create normal menu items for paths with a % in them.')); } if ($form_state['values']['menu']['type'] == 'default tab' || $form_state['values']['menu']['type'] == 'tab') { $bits = explode('/', $path); $last = array_pop($bits); if ($last == '%') { form_error($form['menu']['type'], $form_state, t('A display whose path ends with a % cannot be a tab.')); } } if ($form_state['values']['menu']['type'] != 'none' && empty($form_state['values']['menu']['title'])) { form_error($form['menu']['title'], $form_state, t('Title is required for this menu type.')); } } }