1
|
<?php
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
function bootstrap_file_managed_file($variables) {
|
11
|
$element = $variables['element'];
|
12
|
|
13
|
$attributes = array();
|
14
|
if (isset($element['#id'])) {
|
15
|
$attributes['id'] = $element['#id'];
|
16
|
}
|
17
|
if (!empty($element['#attributes']['class'])) {
|
18
|
$attributes['class'] = (array) $element['#attributes']['class'];
|
19
|
}
|
20
|
$attributes['class'][] = 'form-managed-file';
|
21
|
$attributes['class'][] = 'input-group';
|
22
|
|
23
|
$element['upload_button']['#prefix'] = '<span class="input-group-btn">';
|
24
|
$element['upload_button']['#suffix'] = '</span>';
|
25
|
$element['remove_button']['#prefix'] = '<span class="input-group-btn">';
|
26
|
$element['remove_button']['#suffix'] = '</span>';
|
27
|
|
28
|
if (!empty($element['filename'])) {
|
29
|
$element['filename']['#prefix'] = '<div class="form-control">';
|
30
|
$element['filename']['#suffix'] = '</div>';
|
31
|
}
|
32
|
|
33
|
$hidden_elements = array();
|
34
|
foreach (element_children($element) as $child) {
|
35
|
if ($element[$child]['#type'] === 'hidden') {
|
36
|
$hidden_elements[$child] = $element[$child];
|
37
|
unset($element[$child]);
|
38
|
}
|
39
|
}
|
40
|
|
41
|
|
42
|
$output = '';
|
43
|
$output .= '<div' . drupal_attributes($attributes) . '>';
|
44
|
$output .= drupal_render_children($element);
|
45
|
$output .= '</div>';
|
46
|
$output .= render($hidden_elements);
|
47
|
return $output;
|
48
|
}
|