function _hierarchical_select_process_get_hs_selection in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 hierarchical_select.module \_hierarchical_select_process_get_hs_selection()
- 7.3 hierarchical_select.module \_hierarchical_select_process_get_hs_selection()
Get the current (flat) selection of the hierarchical select.
This selection is updatable by the user, because the values are retrieved from the selects in $element['hierarchical_select']['selects'].
Parameters
$element: A hierarchical_select form element.
Return value
An array (bag) containing the ids of the selected items in the hierarchical select.
1 call to _hierarchical_select_process_get_hs_selection()
- _hierarchical_select_process_calculate_selections in ./
hierarchical_select.module - Calculates the flat selections of both the hierarchical select and the dropbox.
File
- ./
hierarchical_select.module, line 781 - This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
Code
function _hierarchical_select_process_get_hs_selection($element) {
$hs_selection = array();
$config = _hierarchical_select_inherit_default_config($element['#config']);
if (count($element['#value']['hierarchical_select']['selects'])) {
if ($config['save_lineage']) {
foreach ($element['#value']['hierarchical_select']['selects'] as $key => $value) {
$hs_selection[] = $value;
}
}
else {
foreach ($element['#value']['hierarchical_select']['selects'] as $key => $value) {
$hs_selection[] = $value;
}
$hs_selection = _hierarchical_select_hierarchy_validate($hs_selection, $config['module'], $config['params']);
// Get the last valid value. (Only the deepest item gets saved). Make
// sure $hs_selection is an array at all times.
$hs_selection = $hs_selection != -1 ? array(
end($hs_selection),
) : array();
}
}
return $hs_selection;
}