';
- // Add bootstrap class
- if (isset($element['#type']) && ($element['#type'] == "radio" || $element['#type'] == "checkbox")){
- $exclude_control = TRUE;
- }
- else {
- $attributes['class'] = array('control-group');
- }
-
// Check for errors and set correct error class
if (isset($element['#parents']) && form_get_error($element)) {
$attributes['class'][] = 'error';
@@ -106,6 +96,18 @@ function bootstrap_form_element(&$variables) {
$attributes['class'][] = 'form-disabled';
}
$attributes['class'][] = 'form-item';
+
+ // See http://getbootstrap.com/css/#forms-controls.
+ if (isset($element['#type']) ) {
+ if($element['#type'] == "radio") {
+ $attributes['class'][] = 'radio';
+ } elseif ($element['#type'] == "checkbox") {
+ $attributes['class'][] = 'checkbox';
+ } else {
+ $attributes['class'][] = 'form-group';
+ }
+ }
+
$output = '
' . "\n";
// If #title is not set, we don't display any label or required marker.
@@ -122,19 +124,9 @@ function bootstrap_form_element(&$variables) {
case 'before':
case 'invisible':
$output .= ' ' . theme('form_element_label', $variables);
- // Check if item exists in element whitelist
- if (isset($element['#id']) && in_array($element['#id'], $whitelist)) {
- $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
- $exclude_control = TRUE;
- }
- else {
- $output = $exclude_control ? $output : $output.$control_wrapper;
- $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
- }
+ $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
break;
-
case 'after':
- $output = $exclude_control ? $output : $output.$control_wrapper;
$variables['#children'] = ' ' . $prefix . $element['#children'] . $suffix;
$output .= ' ' . theme('form_element_label', $variables) . "\n";
break;
@@ -142,7 +134,6 @@ function bootstrap_form_element(&$variables) {
case 'none':
case 'attribute':
// Output no label and no required marker, only the children.
- $output = $exclude_control ? $output : $output.$control_wrapper;
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
break;
}
@@ -151,13 +142,8 @@ function bootstrap_form_element(&$variables) {
$output .= '
' . $element['#description'] . "
\n";
}
- // Check if control wrapper was added to ensure we close div correctly
- if ($exclude_control) {
- $output .= "