You are here

function Utils::wf_crm_contact_label in Webform CiviCRM Integration 8.5

Parameters

integer $n:

array $data Form data:

string $html Controls how html should be treated. Options are::

  • 'escape': (default) Escape html characters
  • 'wrap': Escape html characters and wrap in a span
  • 'plain': Do not escape (use when passing into an FAPI options list which does its own escaping)

Return value

string

Overrides UtilsInterface::wf_crm_contact_label

File

src/Utils.php, line 575
Webform CiviCRM module's common utility functions.

Class

Utils

Namespace

Drupal\webform_civicrm

Code

function wf_crm_contact_label($n, $data = [], $html = 'escape') {
  $label = trim(wf_crm_aval($data, "contact:{$n}:contact:1:webform_label", ''));
  if (!$label) {
    $label = t('Contact :num', [
      ':num' => $n,
    ]);
  }
  if ($html != 'plain') {
    $label = Html::escape($label);
  }
  if ($html == 'wrap') {
    $label = Markup::create($label);
  }
  return $label;
}