You are here

function webform_preprocess_form_element_label in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.inc \webform_preprocess_form_element_label()

Implements hook_preprocess_form_element_label() for form element label templates.

File

includes/webform.theme.inc, line 562
Theme hooks, preprocessor, and suggestions.

Code

function webform_preprocess_form_element_label(&$variables) {
  $element =& $variables['element'];

  // Fix variable title #markup tha contains a render array which is most
  // likely a Help tooltip.
  // @see template_preprocess_form_element_label()
  // @see webform_preprocess_form_element()
  if (isset($variables['title']) && is_array($variables['title']) && is_array($variables['title']['#markup'])) {
    $variables['title'] = $variables['title']['#markup'];
  }

  // Remove label 'for' attribute.
  if (!empty($element['#attributes']['webform-remove-for-attribute'])) {
    unset($element['#attributes']['webform-remove-for-attribute']);
    unset($variables['attributes']['webform-remove-for-attribute']);
    unset($variables['attributes']['for']);
  }
}