I'm re-building a travel website and need the trip search form to have the "Arrivals" select populated using AJAX once the departures has been selected to remove any empty search results.

I have followed all the tutorials I could find online, namely: Views AJAX Dynamic Dependent Exposed Filters & AJAX populated filter breaks when Views Dependant Filter module added, applied patch #106 from https://www.drupal.org/node/1183418 and nothing seems to work. I'm also not getting any error messages which makes it harder to debug.

I've attached my custom module code to the bottom of this post.

Any help or ideas are appreciated as I've been stuck on this for over a week now.

    function dependant_keyword_filter_form_views_exposed_form_alter(&$form, &$form_state){
    if ($form['#id'] == 'views-exposed-form-trips-page') {

        if($form_state['input']['field_departure_tid'] === 'All')
            $form['field_arrival_tid']['#disabled'] = 1;

function _sort_alphabetically($form, $form_state) {
        foreach ($form_state['view']->filter as $field => $filter) {
            if ($filter->options['exposed']  && $filter->options['id'] == 'field_arrival_tid' ) {
                $field_id = $form['#info']["filter-field_arrival_tid"]['value'];
        return $form;

function _update_arrival_callback($form, $form_state) {
    return $form['field_arrival_tid'];

function _get_associative_array_from_view($viewID, $viewDisplayID, $keyFieldID, $valueFieldID, $contextualFilter){
    $associativeArray = array();
    $associativeArray['All'] = t('- Any -');
    $viewResults = views_get_view_result($viewID, $viewDisplayID, $contextualFilter);
    foreach($viewResults as $viewRow) {
        $associativeArray[$viewRow->$keyFieldID] = $viewRow->$valueFieldID;
    return $associativeArray;

1 Answer 1


Try to change:

if($form_state['input']['field_departure_tid'] === 'All')


if($form_state['input']['field_departure_tid'] == 'All')

And inside _form_alter function add this string to see the content of field_departure_tid


because if I don't wrong remember field_departure_tid is a number not a string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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