function theme_fel_form_element_label in Form element layout 7
Replacement theme for 'form_element_label'.
See also
3 theme calls to theme_fel_form_element_label()
- theme_fel_fields_matrix_table in modules/
fel_fields/ fel_fields.theme.inc - Theme replacement for 'matrix_table'.
- theme_fel_form_element in ./
fel.module - Replacement theme for 'form_element'.
- theme_fel_webform_element in modules/
fel_webform/ fel_webform.module - Replacement for theme_webform_element().
File
- ./
fel.module, line 214 - Reorder #title, #description and #children in forms.
Code
function theme_fel_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 ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
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,
)) : '';
$title = filter_xss_admin($element['#title']);
$attributes = array();
if ($element['#title_display'] != 'invisible' and !empty($element['#title_classes'])) {
$attributes['class'] = $element['#title_classes'];
}
// 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,
)) . "</label>\n";
}