How can I show parents after child term inside a Views exposed filter? I have a vocabulary with states and cities, where city are children of state:



I have an exposed filter with depth. How can I show parent term after child? For example, like this:



I'm confused because the array has no relation between parent and child. For example, this is the form array select box:

{
#type: "select",
#options: {
0: {
option: {
17: "Aragon"
}
},
1: {
option: {
21: "-Barbastro"
}
},
2: {
option: {
20: "-Calatayud"
}
},
3: {
option: {
19: "-Zaragoza"
}
},
4: {
option: {
16: "Cataluña"
}
},
5: {
option: {
22: "-Barcelona"
}
},
6: {
option: {
24: "-Girona"
}
},
7: {
option: {
23: "-Tarragona"
}
},
8: {
option: {
18: "Valencia"
}
},
9: {
option: {
26: "-Alicante"
}
},
10: {
option: {
27: "-Elche"
}
},
11: {
option: {
25: "-Valencia"
}
},
All: "- Any -"
},
#size: "",
#default_value: "All"
},
The exposed taxonomy filter select box form doesn't have any hierarchy built into the select form array (e.g. using subarray to present optgroup elements). Rather, its labels are indented to present the hierarchy on each select option. 

To alter the labels, you can utilize hook_form_views_exposed_form_alter() to alter the selectbox array structure with some string manipulate logic. For example: 

function MYMODULE_form_views_exposed_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $parent = '';
  $options = $form['tid']['#options'];
  foreach ($options as $index =&gt; $option) {
    if (is_object($option)) {
      $label = reset($option-&gt;option);
      $key = key($option-&gt;option);
      if (substr($label, 0, 1) != '-') {
        $parent = $label;
      }
      else {
        $options[$index]-&gt;option[$key] = $options[$index]-&gt;option[$key] . " ($parent)";
      }
    }
  }
}