You are here

function _hierarchical_select_validate in Hierarchical Select 5.2

Same name and namespace in other branches
  1. 5.3 hierarchical_select.module \_hierarchical_select_validate()
  2. 6.3 hierarchical_select.module \_hierarchical_select_validate()
  3. 7.3 hierarchical_select.module \_hierarchical_select_validate()

Hierarchical select form element validate callback.

File

./hierarchical_select.module, line 254
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select an option in a hierarchy.

Code

function _hierarchical_select_validate($element, $settings) {

  // Extract the settings for this hierarchical select from the settings we're
  // receiving via the extra parameter.
  extract($settings);

  // Generate the dropbox again and use it to count the number of lineages
  // that the user selected. This must be below the dropbox limit.
  if ($dropbox_limit > 0) {

    // Zero as dropbox limit means no limit.
    $dropbox = !$multiple ? FALSE : hierarchical_select_get_dropbox($module, $selection, $save_lineage, array(), $params, '');
    if (count($dropbox->lineages) > $dropbox_limit) {
      form_error($element, t("You've selected %select-count items, but you're only allowed to select %dropbox-limit items.", array(
        '%select-count' => count($dropbox->lineages),
        '%dropbox-limit' => $dropbox_limit,
      )));
    }
  }
}