root / drupal7 / sites / all / themes / bootstrap / templates / system / container.func.php @ 1f623f01
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for bootstrap_container().
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Returns HTML to wrap child elements in a container.
|
9 |
*
|
10 |
* Used for grouped form items. Can also be used as a #theme_wrapper for any
|
11 |
* renderable element, to surround it with a <div> and add attributes such as
|
12 |
* classes or an HTML id.
|
13 |
*
|
14 |
* @param array $variables
|
15 |
* An associative array containing:
|
16 |
* - element: An associative array containing the properties of the element.
|
17 |
* Properties used: #id, #attributes, #children.
|
18 |
*
|
19 |
* @return string
|
20 |
* The constructed HTML.
|
21 |
*
|
22 |
* @see theme_container()
|
23 |
*
|
24 |
* @ingroup theme_functions
|
25 |
*/
|
26 |
function bootstrap_container($variables) { |
27 |
$element = $variables['element']; |
28 |
|
29 |
// Ensure #attributes is set.
|
30 |
$element += array('#attributes' => array()); |
31 |
|
32 |
// Special handling for form elements.
|
33 |
if (isset($element['#array_parents'])) { |
34 |
// Assign an html ID.
|
35 |
if (!isset($element['#attributes']['id'])) { |
36 |
$element['#attributes']['id'] = $element['#id']; |
37 |
} |
38 |
|
39 |
// Core's "form-wrapper" class is required for states.js to function.
|
40 |
$element['#attributes']['class'][] = 'form-wrapper'; |
41 |
|
42 |
// Add Bootstrap "form-group" class.
|
43 |
$element['#attributes']['class'][] = 'form-group'; |
44 |
} |
45 |
|
46 |
return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>'; |
47 |
} |