You are here

function theme_addressfield_container in Address Field 7

Render a container for a set of address fields.

File

./addressfield.module, line 329
Defines a field for attaching country-specific addresses to entities.

Code

function theme_addressfield_container($variables) {
  $element = $variables['element'];
  $element['#children'] = trim($element['#children']);

  // Remove the autocomplete attribute because the W3C validator complains.
  // It's only used on forms anyway.
  unset($element['#attributes']['autocomplete']);
  if (strlen($element['#children']) > 0) {
    $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
    $output .= $element['#children'];
    $output .= '</' . $element['#tag'] . '>';

    // Add a linebreak to the HTML after a div. This is invisible on the
    // rendered page but improves the appearance of address field output when
    // HTML tags are stripped, such as by Views Data Export.
    if ($element['#tag'] == 'div') {
      $output .= PHP_EOL;
    }
    return $output;
  }
  else {
    return '';
  }
}