You are here

function fc_form_element_label in Field Complete 7

Modified form_element_label theme function.

1 string reference to 'fc_form_element_label'
fc_theme_registry_alter in ./fc.module
Implements hook_theme_registry_alter().

File

./fc.module, line 199
Field Complete - Provides field-based completeness for any entity.

Code

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

  // This is also used in the installer, pre-database setup.
  $t = get_t();

  // If title and required marker are both empty, output no label.
  if (empty($element['#title'])) {
    return '';
  }

  // If the element is required, a required marker is appended to the label.
  $required = !empty($element['#required']) ? theme('form_required_marker', array(
    'element' => $element,
  )) : '';
  $complete = !empty($element['#field_complete']) ? theme('form_complete_marker', array(
    'element' => $element,
  )) : '';
  $title = filter_xss_admin($element['#title']);
  $attributes = array();

  // Style the label as class option to display inline with the element.
  if ($element['#title_display'] == 'after') {
    $attributes['class'] = 'option';
  }
  elseif ($element['#title_display'] == 'invisible') {
    $attributes['class'] = 'element-invisible';
  }
  if (!empty($element['#id'])) {
    $attributes['for'] = $element['#id'];
  }

  // The leading whitespace helps visually separate fields from inline labels.
  return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array(
    '!title' => $title,
    '!required' => $required . $complete,
  )) . "</label>\n";
}