Look at my currently developing site's exposed filter(where 'Бренд' and 'Модель' fields): Link
If you want to achive this kind of functionality then you can achieve it like this. First you need to alter exposed filter function:
function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state) {
if ($form['#id'] == 'views-exposed-form-VIEWS_NAME_VIEWS_DISPLAY') {
if(!empty($form_state['values'])) {
$form_state['input'] = array_merge($form_state['input'],$form_state['values']);
}
// Marks
$mark_childs = populate_terms_by_vocab('transport_models', TRUE, FALSE);
$form['field_adv_mark_tid']['#options'] = array('All' => t('--Выберите')) + $mark_childs;
$form['field_adv_mark_tid']['#ajax'] = array(
'callback' => 'adv_mark_callback',
'wrapper' => 'model-wrapper',
'effect' => 'none',
'progress' => array(
'type' => 'throbber',
'message' => '',
),
);
// marks end
// Models begin
$selectedMark = isset($form_state['input']['field_adv_mark_tid']) ? $form_state['input']['field_adv_mark_tid'] : NULL;
if($selectedMark != NULL || $selectedMark != FALSE) {
$model_childs = populate_terms_by_vocab('transport_models', FALSE, $selectedMark);
}
elseif($selectedMark == NULL || $selectedMark == FALSE) {
$model_childs = array();
}
$form['field_adv_model_tid']['#options'] = array('All' => t('--Выберите')) + $model_childs;
$form['field_adv_model_tid']['#prefix'] = '<div id="model-wrapper">';
$form['field_adv_model_tid']['#suffix'] = '</div>';
// models end
}
}
// This is an Ajax callback for $form['field_adv_mark_tid']['#ajax']
function adv_mark_callback($form, $form_state) {
return $form['field_adv_model_tid'];
}
// This is a helper function which returns terms (suitable for form selectlist, checkboxes or radios..)
function populate_terms_by_vocab($vocabulary_machine_name, $only_parents = TRUE, $parent = FALSE) {
$vocab = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name);
$terms = array();
if($parent == FALSE) {
$terms = taxonomy_get_tree($vocab->vid, 0, NULL, FALSE);
}
elseif($parent == TRUE) {
$terms = taxonomy_get_tree($vocab->vid, $parent, NULL, FALSE);
}
$child_terms = array();
foreach($terms as $key => $value) {
if($only_parents && $terms[$key]->parents[0] == 0) {
$child_terms[$terms[$key]->tid] = $terms[$key]->name;
}
elseif($only_parents == FALSE && $terms[$key]->parents[0] != 0) {
$child_terms[$terms[$key]->tid] = $terms[$key]->name;
}
}
return $child_terms;
}
I thinks the logic is the same.. In my case, I am adding to my entity type the two same term reference fields, and on content creation form I am displaying them as different parent field and child field (with pre-render function). By that, first field is holding the top level terms, the second field is holding child terms. And by views ui I am exposing them separately. And, that piece of code is displaying them as I want..