Hierarchical select default_value as an array?
ilakshmir - November 6, 2009 - 14:17
| Project: | Hierarchical Select |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I am using an HS element in a form (with hs_taxonomy module). I can set the default_value of the HS element to a single tid and it works as expected (example: '#default_value' => '4'). But I cannot get it working if I set the default_value as an array ($a = array('4','10','14'); '#default_value' => array_values($a),).
The code for content_taxonomy seems to set the default_value via an array ( '#default_value' => !empty($selected_items) ? array_values($selected_items) : array(),).
Is this a bug or intended behavior? Any insights?
Thanks

#1
It depends on your config. Please post your HS config, so I can give a proper explanation based on that.
#2
Wim, thanks for your response. Here is the configuration I am using:
$form['tag'] = array(
'#type' => 'hierarchical_select',
//'#default_value' => array_values(array('8', '9', '15')),
//'#default_value' => '11',
'#config' => array(
'module' => 'hs_taxonomy',
'params' => array(
'vid' => 2,
),
'save_lineage' => 0,
'enforce_deepest' => 1,
'entity_count' => 0,
'require_entity' => 0,
'resizable' => 1,
'level_labels' => array(
'status' => 1,
),
'dropbox' => array(
'status' => 0,
'title' => t('All selections'),
'limit' => 0,
'reset_hs' => 1,
),
'editability' => array(
'status' => 0,
'item_types' => array(),
'allowed_levels' => array(
0 => 0,
1 => 0,
2 => 1,
),
'allow_new_levels' => 0,
'max_levels' => 3,
),
// These settings cannot be configured through the UI: they can only be
// overridden through code.
'animation_delay' => 400,
'special_items' => array('8' => array('none'),),
'render_flat_select' => 0,
'path' => 'hierarchical_select_json',
),
);