1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to set a default value for Simple hierarchical select?

Discussion in 'Programming/Internet' started by Yuriy Kosyanchuk, Oct 8, 2018.

  1. I tried to implement hook_form_alter in order to pass default value to Simple hierarhical select views exposed filter.

    function mymodule_form_alter(&$form, &$form_state, $form_id) {
    $tid = get_tid_from_termalias (arg(1)); // here I get tid
    $form_state['input']['field_sity1_tid'] = (!empty($tid)) ? $tid : 'All';
    $form_state['field_sity1_tid']['#value'] = (!empty($tid)) ? $tid : 'All';
    $form['field_sity1_tid']['#default_value'] = (!empty($tid)) ? $tid : 'All';
    $form['field_sity1_tid']['#value'] = (!empty($tid)) ? $tid : 'All';
    }


    I see that shs.js creates 2 selects, one hidden and one shown. My code changes only the value in the hidden select while second select always remains 'All'. How to change the visible select's default value?

    Login To add answer/comment
     

Share This Page