function views_plugin_display_page::options_validate

3.x views_plugin_display_page.inc views_plugin_display_page::options_validate(&$form, &$form_state)
2.x views_plugin_display_page.inc views_plugin_display_page::options_validate(&$form, &$form_state)

Validate the options form.

Overrides views_plugin_display::options_validate

File

plugins/views_plugin_display_page.inc, line 480
Contains the page display plugin.

Class

views_plugin_display_page
The plugin that handles a full page.

Code

function options_validate(&$form, &$form_state) {
  // It is very important to call the parent function here:
  parent::options_validate($form, $form_state);
  switch ($form_state['section']) {
    case 'path':
      if (strpos($form_state['values']['path'], '$arg') !== FALSE) {
        form_error($form['path'], t('"$arg" is no longer supported. Use % instead.'));
      }

      if (strpos($form_state['values']['path'], '%') === 0) {
        form_error($form['path'], t('"%" may not be used for the first segment of a path.'));
      }

      // automatically remove '/' and trailing whitespace from path.
      $form_state['values']['path'] = trim($form_state['values']['path'], '/ ');
      break;
    case 'menu':
      $path = $this->get_option('path');
      if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) {
        form_error($form['menu']['type'], 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'], 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'], t('Title is required for this menu type.'));
      }
      break;
  }
}