function theme_container

Returns HTML to wrap child elements in a container.

Used for grouped form items. Can also be used as a #theme_wrapper for any renderable element, to surround it with a <div> and add attributes such as classes or an HTML id.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #id, #attributes, #children.

Related topics

File

drupal/core/includes/form.inc, line 3422
Functions for form and batch generation and processing.

Code

function theme_container($variables) {
  $element = $variables['element'];

  // Special handling for form elements.
  if (isset($element['#array_parents'])) {

    // Assign an html ID.
    if (!isset($element['#attributes']['id'])) {
      $element['#attributes']['id'] = $element['#id'];
    }

    // Add the 'form-wrapper' class.
    $element['#attributes']['class'][] = 'form-wrapper';
  }
  return '<div' . new Attribute($element['#attributes']) . '>' . $element['#children'] . '</div>';
}