1 |
87dbc3bf
|
Benjamin Luce
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
function bootstrap_button($variables) {
|
11 |
|
|
$element = $variables['element'];
|
12 |
|
|
$label = $element['#value'];
|
13 |
|
|
element_set_attributes($element, array('id', 'name', 'value', 'type'));
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
$button_classes = array(
|
17 |
|
|
'btn-default',
|
18 |
|
|
'btn-primary',
|
19 |
|
|
'btn-success',
|
20 |
|
|
'btn-info',
|
21 |
|
|
'btn-warning',
|
22 |
|
|
'btn-danger',
|
23 |
|
|
'btn-link',
|
24 |
|
|
);
|
25 |
|
|
$class_intersection = array_intersect($button_classes, $element['#attributes']['class']);
|
26 |
|
|
if (empty($class_intersection)) {
|
27 |
|
|
$element['#attributes']['class'][] = 'btn-default';
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
$element['#attributes']['class'][] = 'form-' . $element['#button_type'];
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
return '<button' . drupal_attributes($element['#attributes']) . '>' . $label . "</button>\n";
|
35 |
|
|
} |