You are here

function name_element_expand in Name Field 6

Same name and namespace in other branches
  1. 8 name.module \name_element_expand()
  2. 7 name.module \name_element_expand()

The #process callback to create the element.

1 string reference to 'name_element_expand'
name_elements in ./name.module
Implementation of hook_elements().

File

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

Code

function name_element_expand($element, $edit, &$form_state, $complete_form) {
  $element['#tree'] = TRUE;
  if (empty($element['#value'])) {
    $element['#value'] = array();
  }
  $element['#value'] += array(
    'title' => '',
    'given' => '',
    'middle' => '',
    'family' => '',
    'generational' => '',
    'credentials' => '',
  );
  $components = $element['#components'];
  $min_components = (array) $element['#minimum_components'];
  foreach (_name_translations() as $key => $title) {
    if (!isset($components[$key]['exclude'])) {
      $element[$key] = _name_render_component($components[$key], $key, $element['#value'][$key], isset($min_components[$key]));
      if ($key == 'credentials') {
        $element[$key]['#prefix'] = '<div class="clear-block" style="float: left;">';
        $element[$key]['#suffix'] = '</div>';
      }
      else {
        $element[$key]['#prefix'] = '<div style="float: left; margin-right: 1em;">';
        $element[$key]['#suffix'] = '</div>';
      }
    }
  }

  // Try to prevent wrapping errors without any additional styles.
  $element['#prefix'] = '<div class="clear-block">';
  $element['#suffix'] = '</div>';
  $element['#pre_render'] = array(
    'name_element_pre_render',
  );
  return $element;
}