You are here

function _webform_display_civicrm_contact in Webform CiviCRM Integration 7.5

Same name and namespace in other branches
  1. 7.3 contact_component.inc \_webform_display_civicrm_contact()
  2. 7.4 includes/contact_component.inc \_webform_display_civicrm_contact()

Implements _webform_display_component().

File

includes/contact_component.inc, line 587

Code

function _webform_display_civicrm_contact($component, $value, $format = 'html') {
  $display = empty($value[0]) ? '' : wf_crm_display_name($value[0]);
  if ($format == 'html' && $display && user_access('access CiviCRM')) {
    $display = l($display, 'civicrm/contact/view', [
      'alias' => TRUE,
      'query' => [
        'reset' => 1,
        'cid' => $value[0],
      ],
    ]);
  }
  return [
    '#title' => $component['name'],
    '#weight' => $component['weight'],
    '#theme' => 'display_civicrm_contact',
    '#theme_wrappers' => $format == 'html' ? [
      'webform_element',
    ] : [
      'webform_element_text',
    ],
    '#field_prefix' => '',
    '#field_suffix' => '',
    '#format' => $format,
    '#value' => $display,
    '#translatable' => [
      'title',
    ],
  ];
}