You are here

function webform_civicrm_js_options in Webform CiviCRM Integration 7.2

Same name and namespace in other branches
  1. 6.2 webform_civicrm_utils.inc \webform_civicrm_js_options()
  2. 6 webform_civicrm_utils.inc \webform_civicrm_js_options()
  3. 7 webform_civicrm_utils.inc \webform_civicrm_js_options()

Callback to serve AJAX requests.

1 string reference to 'webform_civicrm_js_options'
webform_civicrm_menu in ./webform_civicrm.module
Implements hook_menu().

File

./webform_civicrm_utils.inc, line 1061
Webform CiviCRM module's common utility functions. The code in this file is cross-compatible with D6/Civi3 and D7/Civi4 Drupal-version-specific functions belong in webform_civicrm_dx_functions.inc

Code

function webform_civicrm_js_options($key, $str = '') {

  // Populate state/prov lists on the fly
  if ($key == 'state_province') {
    if (!$str || intval($str) != $str && $str != 'default') {
      webform_civicrm_json(array(
        '' => t('- first choose a country -'),
      ));
    }
    civicrm_initialize();
    webform_civicrm_json(webform_civicrm_get_options('state_province', $str));
  }

  // Serve AHAH requests for D6
  if (substr($key, 0, 12) == 'civicrm_ahah' && user_access('access CiviCRM')) {
    webform_civicrm_ahah_callback($key);
  }
  return drupal_not_found();
}