function _hs_process_render_flat_select in Hierarchical Select 7.3
Render a flat select version of a hierarchical_select form element. This is necessary for backwards compatibility (together with some Javascript code) in case of GET forms.
Parameters
$hierarchy: A hierarchy object.
$dropbox: A dropbox object.
$config: A config array with at least the following settings:
- module
- params
- dropbox
- status
Return value
A structured array for use in the Forms API.
1 call to _hs_process_render_flat_select()
- form_hierarchical_select_process in ./
hierarchical_select.module - Hierarchical select form element type #process callback.
File
- ./
hierarchical_select.module, line 1344 - 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 _hs_process_render_flat_select($hierarchy, $dropbox, $config) {
$selection = array();
if ($config['dropbox']['status']) {
foreach ($dropbox->lineages_selections as $lineage_selection) {
$selection = array_merge($selection, $lineage_selection);
}
}
else {
$selection = $hierarchy->lineage;
}
$options = array();
foreach ($selection as $value) {
$is_valid = module_invoke($config['module'], 'hierarchical_select_valid_item', $value, $config['params']);
if ($is_valid) {
$options[$value] = $value;
}
}
$element = array(
'#type' => 'select',
'#multiple' => $config['save_lineage'] || $config['dropbox']['status'],
'#options' => $options,
'#value' => array_keys($options),
// Use a #theme callback to prevent the select from being wrapped in a
// div. This simplifies the CSS and JS code.
'#theme' => 'hierarchical_select_select',
'#attributes' => array(
'class' => array(
'flat-select',
),
),
);
return $element;
}