function theme_static_contact_element in Webform CiviCRM Integration 7.3
Same name and namespace in other branches
- 7.5 includes/contact_component.inc \theme_static_contact_element()
- 7.4 includes/contact_component.inc \theme_static_contact_element()
Theme the wrapper for a static contact element Includes normal webform theme wrappers plus a tokeninput-style name field
File
- ./
contact_component.inc, line 968
Code
function theme_static_contact_element($vars) {
$element = $vars['element'];
$component = $element['#webform_component'];
// All elements using this for display only are given the "display" type.
$type = wf_crm_aval($element, '#format') == 'html' ? 'display' : 'civicrm_contact';
// Convert the parents array into a string, excluding the "submitted" wrapper.
$nested_level = $element['#parents'][0] == 'submitted' ? 1 : 0;
$parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], $nested_level)));
$wrapper_classes = array(
'form-item',
'webform-component',
'webform-component-' . $type,
'static',
);
if ($component['extra']['title_display'] === 'inline') {
$wrapper_classes[] = 'webform-container-inline';
}
$output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n";
// Display static value in addition to hidden field
if ($type == 'civicrm_contact' && !empty($element['#attributes']['data-civicrm-name'])) {
if ($component['extra']['title_display'] != 'none') {
$output .= ' <label for="' . $element['#id'] . '">' . check_plain($component['name']) . "</label>\n";
}
$output .= '<ul class="token-input-list"><li class="token-input-token"><p>' . $element['#attributes']['data-civicrm-name'] . "</p></li></ul>\n";
if (!empty($component['extra']['description'])) {
$output .= ' <div class="description">' . filter_xss($component['extra']['description']) . "</div>\n";
}
}
return $output . $element['#children'] . "\n</div>\n";
}