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
Comments
Comment #1
wim leersIt depends on your config. Please post your HS config, so I can give a proper explanation based on that.
Comment #2
ilakshmir commentedWim, 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',
),
);
Comment #3
wim leersSorry for the late reply!
You've got:
'save_lineage' => 0,and
Multiple values are only supported when you've got either of those enabled. save_lineage will require the multiple values to belong to the same term lineage. Enabling the dropbox will allow you store multiple values: multiple lineages (i.e. multiple multiple terms) when save_lineage is also enabled or multiple terms (i.e. multiple single terms) when save_lineage is disabled.