I have a vocabulary like the following:

Parent 1 Child 1 Child 2

Parent 2 Child 3 Child 4

I want the dropdown only to show Parent 2 and its childs, so I changed the root_term id to parent id

'root_term' => termid, // Enter a term ID here if you want to display only terms below the term with that ID.

function mymodule_alter_form_alter(&$form, &$form_state, $form_id) {

if($form_id == 'myform_node_form')
  $form['field_myfield']['und']['#config']['params']['root_term']= termid;

Please let me know how to achieve this ??


As I explained in this link ,this is bug in HS module.

finally i found your mistake in your code , in hs_taxonomy.module in function hs_taxonomy_hierarchical_select_root_level($params) you don't consider $params['root_term'] and in every hs this item bypassed by 0 value

$terms = _hs_taxonomy_hierarchical_select_get_tree($params['vid'], 0, -1, 1);

must be

$terms = _hs_taxonomy_hierarchical_select_get_tree($params['vid'], $params['root_term'], -1, 1);

if user not set parent in content_taxonomy settings for term reference it passed 0 by default.

please apply this patch to your module. just notice for this work correctly you want select (not duplicate second level select option) Save term lineage in Hierarchical Select configuration in Save lineage part. i test it ,working like a 'BENZ'

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.