You are here

function taxonomy_menu_custom_paths_vocabulary_validate in Taxonomy menu 7.2

Same name and namespace in other branches
  1. 8 taxonomy_menu_custom_paths/taxonomy_menu_custom_paths.module \taxonomy_menu_custom_paths_vocabulary_validate()

Validation handler for settings of custom path in the taxonomy vocabulary.

We make sure that a base path is provided and paths are registered.

See also

taxonomy_form_vocabulary()

1 string reference to 'taxonomy_menu_custom_paths_vocabulary_validate'
taxonomy_menu_custom_paths_form_taxonomy_form_vocabulary_alter in taxonomy_menu_custom_paths/taxonomy_menu_custom_paths.module
Implements hook_form_FORM_ID_alter().

File

taxonomy_menu_custom_paths/taxonomy_menu_custom_paths.module, line 67
taxonomy_menu_custom_paths module

Code

function taxonomy_menu_custom_paths_vocabulary_validate($form, $form_state) {
  $options = $form_state['values']['taxonomy_menu'];
  $base = $options['options_custom_path']['custom_path_base'];
  $depth = $options['options_custom_path']['custom_path_depth'];

  // Don't allow base path value to be empty when a custom path is selected.
  // Check that the required path are registered in Drupal before processing.
  if ($options['path'] == 'taxonomy_menu_path_custom') {
    if (empty($base)) {
      form_set_error('custom_path_base', 'A base path must be provided when using a custom path.');
    }
    elseif (empty($depth)) {
      $path = drupal_get_normal_path($base . '/%');
      if (!_taxonomy_menu_valid_path($path)) {
        form_set_error('custom_path_base', 'The path ' . $path . ' is not available in Drupal. This is required to use custom paths.');
      }
    }
    else {
      $path = drupal_get_normal_path($base . '/%/%');
      if (!_taxonomy_menu_valid_path($path)) {
        form_set_error('custom_path_depth', 'The path ' . $path . ' is not available in Drupal. This is required to use custom paths.');
      }
    }
  }
}