1 form.inc theme_fieldset($variables)

Returns HTML for a fieldset form element and its children.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #attributes, #children, #collapsed, #collapsible, #description, #id, #title, #value.

Related topics

File

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

Code

function theme_fieldset($variables) {
  $element = $variables['element'];
  element_set_attributes($element, array('id'));
  _form_set_class($element, array('form-wrapper'));

  $output = '<fieldset' . backdrop_attributes($element['#attributes']) . '>';
  if (!empty($element['#title'])) {
    // Always wrap fieldset legends in a SPAN for CSS positioning.
    $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
  }
  $output .= '<div class="fieldset-wrapper">';

  $description_before = '';
  $description_after = '';
  if (!empty($element['#description'])) {
    $description = theme('form_element_description', $variables);

    switch ($element['#description_display']) {
      case 'before':
        $description_before = $description;
        break;

      case 'after':
      case 'invisible':
        $description_after = $description;
        break;
    }
  }

  $output .= $description_before;
  $output .= $element['#children'];
  if (isset($element['#value'])) {
    $output .= $element['#value'];
  }
  $output .= $description_after;
  $output .= '</div>';
  $output .= "</fieldset>\n";
  return $output;
}