You are here

function name_element_pre_render in Name Field 7

Same name and namespace in other branches
  1. 8 name.module \name_element_pre_render()
  2. 6 name.module \name_element_pre_render()

This function themes the element and controls the title display.

1 string reference to 'name_element_pre_render'
name_element_info in ./name.module
Implements hook_element_info().

File

./name.module, line 802
Defines an API for displaying and inputing names.

Code

function name_element_pre_render($element) {

  // Add a wrapper to fields if required.
  if (variable_get('name_element_wrapper', 1)) {
    $element['_name'] = array(
      '#prefix' => '<div class="clearfix">',
      '#suffix' => '</div>',
    );
  }
  foreach (_name_translations() as $key => $title) {
    if (isset($element[$key])) {
      $element['_name'][$key] = $element[$key];
      unset($element[$key]);
    }
  }
  if (!empty($element['#component_layout'])) {
    _name_component_layout($element['_name'], $element['#component_layout']);
  }
  if (!empty($element['#description'])) {
    $field = isset($element['#field']) ? $element['#field'] : NULL;
    if (!$field || $field['cardinality'] != 1) {
      $element['_description'] = array(
        '#value' => '<div class="clearfix description">' . $element['#description'] . '</div>',
      );
      unset($element['#description']);
    }
  }
  return $element;
}