You are here

function _ajax_example_get_second_dropdown_options in Examples for Developers 7

Helper function to populate the second dropdown.

This would normally be pulling data from the database.

Parameters

string $key: This will determine which set of options is returned.

Return value

array Dropdown options

Related topics

2 calls to _ajax_example_get_second_dropdown_options()
ajax_example_dependent_dropdown in ajax_example/ajax_example.module
AJAX-based dropdown example form.
ajax_example_dependent_dropdown_degrades in ajax_example/ajax_example_graceful_degradation.inc
Dropdown form based on previous choices.

File

ajax_example/ajax_example.module, line 649
AJAX Examples module file with basic examples.

Code

function _ajax_example_get_second_dropdown_options($key = '') {
  $options = array(
    t('String') => drupal_map_assoc(array(
      t('Violin'),
      t('Viola'),
      t('Cello'),
      t('Double Bass'),
    )),
    t('Woodwind') => drupal_map_assoc(array(
      t('Flute'),
      t('Clarinet'),
      t('Oboe'),
      t('Bassoon'),
    )),
    t('Brass') => drupal_map_assoc(array(
      t('Trumpet'),
      t('Trombone'),
      t('French Horn'),
      t('Euphonium'),
    )),
    t('Percussion') => drupal_map_assoc(array(
      t('Bass Drum'),
      t('Timpani'),
      t('Snare Drum'),
      t('Tambourine'),
    )),
  );
  if (isset($options[$key])) {
    return $options[$key];
  }
  else {
    return array();
  }
}