You are here

function wf_crm_get_contact_types in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/utils.inc \wf_crm_get_contact_types()
  2. 7.3 webform_civicrm_utils.inc \wf_crm_get_contact_types()

Get contact types and sub-types Unlike pretty much every other option list CiviCRM wants "name" instead of "id"

Return value

array

7 calls to wf_crm_get_contact_types()
wf_crm_admin_component::alterForm in includes/wf_crm_admin_component.inc
Alter back-end webform component edit forms. Called by hook_form_alter() whenever editing a webform component.
wf_crm_admin_form::buildContactTab in includes/wf_crm_admin_form.inc
Build fields for a contact
wf_crm_admin_form::insertComponent in includes/wf_crm_admin_form.inc
Add a CiviCRM field to a webform
wf_crm_admin_form::rebuildData in includes/wf_crm_admin_form.inc
Build $this->data array for webform settings; called while rebuilding or post-processing the admin form.
wf_crm_field_options in includes/utils.inc
Get options for a specific field

... See full list

File

includes/utils.inc, line 296
Webform CiviCRM module's common utility functions.

Code

function wf_crm_get_contact_types() {
  static $contact_types = array();
  static $sub_types = array();
  if (!$contact_types) {
    $data = wf_crm_apivalues('contact_type', 'get', array(
      'is_active' => 1,
    ));
    foreach ($data as $type) {
      if (empty($type['parent_id'])) {
        $contact_types[strtolower($type['name'])] = $type['label'];
        continue;
      }
      $sub_types[strtolower($data[$type['parent_id']]['name'])][$type['name']] = $type['label'];
    }
  }
  return array(
    $contact_types,
    $sub_types,
  );
}