'before', ); // Add wrapper ID for 'item' type. if ($type && $type === 'item' && isset($element['#markup']) && !empty($element['#id'])) { $wrapper_attributes['id'] = $element['#id']; } // Check for errors and set correct error class. if ((isset($element['#parents']) && form_get_error($element) !== NULL) || (!empty($element['#required']) && (!isset($element['#value']) || $element['#value'] === '') && bootstrap_setting('forms_required_has_error'))) { $wrapper_attributes['class'][] = 'has-error'; } // Add necessary classes to wrapper container. $wrapper_attributes['class'][] = 'form-item'; if ($name) { $wrapper_attributes['class'][] = 'form-item-' . drupal_html_class($name); } if ($type) { $wrapper_attributes['class'][] = 'form-type-' . drupal_html_class($type); } if (!empty($element['#attributes']['disabled'])) { $wrapper_attributes['class'][] = 'form-disabled'; } if (!empty($element['#autocomplete_path']) && drupal_valid_path($element['#autocomplete_path'])) { $wrapper_attributes['class'][] = 'form-autocomplete'; } // Checkboxes and radios do no receive the 'form-group' class, instead they // simply have their own classes. if ($checkbox || $radio) { $wrapper_attributes['class'][] = drupal_html_class($type); } elseif ($form_group) { $wrapper_attributes['class'][] = 'form-group'; } // Create a render array for the form element. $build = array( '#form_group' => $form_group, '#attributes' => $wrapper_attributes, ); if ($wrapper) { $build['#theme_wrappers'] = array('container__form_element'); // Render the label for the form element. /* @noinspection PhpUnhandledExceptionInspection */ $build['label'] = array( '#markup' => theme('form_element_label', $variables), '#weight' => $element['#title_display'] === 'before' ? 0 : 2, ); } // Checkboxes and radios render the input element inside the label. If the // element is neither of those, then the input element must be rendered here. if (!$checkbox && !$radio) { $prefix = isset($element['#field_prefix']) ? $element['#field_prefix'] : ''; $suffix = isset($element['#field_suffix']) ? $element['#field_suffix'] : ''; if ((!empty($prefix) || !empty($suffix)) && (!empty($element['#input_group']) || !empty($element['#input_group_button']))) { if (!empty($element['#field_prefix'])) { $prefix = '
'; } if (!empty($element['#field_suffix'])) { $suffix = ' '; } // Add a wrapping container around the elements. $input_group_attributes = &_bootstrap_get_attributes($element, 'input_group_attributes'); $input_group_attributes['class'][] = 'input-group'; $prefix = '