1 |
87dbc3bf
|
Benjamin Luce
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
function bootstrap_form_element_label(&$variables) {
|
11 |
|
|
$element = $variables['element'];
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
$t = get_t();
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
$skip = (isset($element['#type']) && ('checkbox' === $element['#type'] || 'radio' === $element['#type']));
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
if ((!isset($element['#title']) || $element['#title'] === '' && !$skip) && empty($element['#required'])) {
|
21 |
|
|
return '';
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
$required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
|
26 |
|
|
|
27 |
|
|
$title = filter_xss_admin($element['#title']);
|
28 |
|
|
|
29 |
|
|
$attributes = array();
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
if ($element['#title_display'] == 'after' && !$skip) {
|
33 |
|
|
$attributes['class'][] = $element['#type'];
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
elseif ($element['#title_display'] == 'invisible') {
|
37 |
|
|
$attributes['class'][] = 'element-invisible';
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
if (!empty($element['#id'])) {
|
41 |
|
|
$attributes['for'] = $element['#id'];
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
$output = '';
|
46 |
|
|
if (isset($variables['#children'])) {
|
47 |
|
|
$output .= $variables['#children'];
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
$output .= $t('!title !required', array('!title' => $title, '!required' => $required));
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
return ' <label' . drupal_attributes($attributes) . '>' . $output . "</label>\n";
|
55 |
|
|
} |