function webform_civicrm_replace_tokens in Webform CiviCRM Integration 6
Same name and namespace in other branches
- 6.2 webform_civicrm_utils.inc \webform_civicrm_replace_tokens()
- 7 webform_civicrm_utils.inc \webform_civicrm_replace_tokens()
- 7.2 webform_civicrm_utils.inc \webform_civicrm_replace_tokens()
Token replacement for form messages
2 calls to webform_civicrm_replace_tokens()
- webform_civicrm_set_message in ./
webform_civicrm_utils.inc - Displays the admin-defined message with "not you?" link to known contacts
- _webform_civicrm_webform_frontend_form_alter in ./
webform_civicrm_forms.inc - Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display message. Block unknown users. Set webform default values.
File
- ./
webform_civicrm_utils.inc, line 606 - Webform CiviCRM module's utility functions.
Code
function webform_civicrm_replace_tokens($str, $contact) {
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
$tokens = webform_civicrm_get_fields('tokens');
$values = array();
foreach ($tokens as $k => &$t) {
$value = $contact[$k];
if (is_array($value)) {
$value = implode(', ', $value);
}
$values[] = str_replace($sp, ' & ', trim($value, $sp));
$t = "[{$t}]";
}
return str_ireplace($tokens, $values, $str);
}