2

I've created a view of users. It includes two exposed filters as drop downs to filter the list. One is for the city and the other for the squadron. The squadron drop down is related to the cities as cities is a taxonomy vocabulary that gets added to squadrons. I would like to find out if it is possible, that when someone selects a city, to automatically filter the squadron drop down filter by that term.

I did this in a form for creating squadrons using ajax (node/add - with help here: see Dynamic select list in the form (dependent dropdown)) but don't know how to do it (or if it is possible to do) in a view exposed filter.

Many thanks in advance

(edit: I'm using D7 and Views 3)

  • Yes, it's possible, but the previous post won't help you. Why? And how to solve this problem? - read this: drupal.org/node/1183418 – ACD Jul 17 '12 at 18:04
  • Hi ACD, thanks very much for your reply and the link. – Ben Jul 18 '12 at 9:59
-1

I haven't check but

{
  $form['computer_stats']['os'] = array(
    '#title' => t('Operating system'),
    '#type' => 'select',
    '#options' => drupal_map_assoc(array('', t('OSX'), t('Linux'), t('Windows'))),
    '#ajax' => array(
      'callback' => 'input_os_verify_ajax_callback',
      'wrapper' => 'input_os_verify_wrapper',
     ),
  );

  // Setting an empty element with a wrapper to be populated.
  $form['computer_stats']['os_verify'] = array(
    '#type' => 'markup',
    '#prefix' => '<div id="input_os_verify_wrapper">',
    '#suffix' => '</div>',
  );

  // When submitted, check for value of OS, and populate os_verify.
  if (isset($form_state['values']['os'])) { // Fixed this line, was throwing an error in the original video code.
    $form['computer_stats']['os_verify']['#type'] = 'checkbox';
    $form['computer_stats']['os_verify']['#title'] = t('Are you sure you are using @os?', array('@os' => $form_state['values']['os']));
  }

  ...
}


function input_os_verify_ajax_callback($form, $form_state) {
  return $form['computer_stats']['os_verify'];
}

from How to Build Beautiful Forms in Drupal 7 (Video Presentation) might help

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