You are here

protected function AjaxController::stateProvince in Webform CiviCRM Integration 8.5

1 call to AjaxController::stateProvince()
AjaxController::handle in src/Controller/AjaxController.php
Handles the ajax request.

File

src/Controller/AjaxController.php, line 58

Class

AjaxController

Namespace

Drupal\webform_civicrm\Controller

Code

protected function stateProvince($input, $isBilling = FALSE) {
  if (!$input || (int) $input != $input && $input != 'default') {
    $data = [
      '' => t('- first choose a country'),
    ];
  }
  else {
    $data = \Drupal::service('webform_civicrm.utils')
      ->wf_crm_get_states($input, $isBilling);
  }

  // @todo use Drupal's cacheable response?
  return new JsonResponse($data);
}