I have a form with a hierarchical select element and an activeselect element. I would like to be able to change the valid list of options on the activeselect element once the user has selected a value from the deepest level of the hierarchical select element.
For example :
$form['item1'] = array(
'#type' => 'hierarchical_select',
'#title' => t('Item 1'),
'#size' => 1,
'#config' => array(
'config_id' => 'taxonomy-views-viewname-26',
'save_lineage' => 0,
'enforce_deepest' => 0,
'entity_count' => 0,
'resizable' => 0,
'level_labels' => array(
'status' => 0,
'labels' => array(
'0' => '',
'1' => '')),
'dropbox' => array(
'status' => 0,
'limit' => 0,
'reset_hs' => 1,
'title' => ''),
'editability' => array(
'status' => 0,
'item_types' => array(),
'allowed_levels' => array(),
'allow_new_levels' => 0,
'max_levels' => 3),
'module' => 'hs_taxonomy_views',
'params' => array(
'optional' => '',
'vid' => 26,
'exclude_tid' => '',
'root_term' => ''),
'exclusive_lineages' => array('0' => '**ALL**'),
'render_flat_select' => 1,
),
);
$form['item2'] = array(
'#tree' => 1,
'nids' => array(
'#type' => 'activeselect',
'#title' => 'Item 2',
'#multiple' => 0,
'#size' => 0,
'#options' => array(
0 => 'All'
),
'#required' => 0,
'#description' => '',
'#theme' => 'activeselect',
'#activeselect_path' => 'activepath',
'#activeselect_targets' => 'item3',
),
);
Is this possible ? My JavaScript is not the best, but can I do this with the change-hierarchical-select event or is there a hierarchical select hook I can use ?
I tried using the ahah forms bindings, but they did not fire when attached the hierarchical select element above.
Thanks
Comments
Comment #1
wim leers#ahahwon't work, you'll have to write some custom JS. Thechange-hierarchical-selectevent is indeed the one you want.Comment #2
drenton commentedThanks Wim. This is what I did to get it working.
Added this JavaScript to my form :
Added this to our module :
Comment #3
wim leersCool, thanks for posting that! I'm sure it'll be useful for others :)
Comment #5
Ashu commentedThanks
it really helped... :)