You are here

function _name_defaults in Name Field 6

Same name and namespace in other branches
  1. 7 includes/name.content.inc \_name_defaults()

Helper function to set the defaults for a name field / widget.

3 calls to _name_defaults()
name_field_settings in ./name.module
Implementation of hook_field_settings().
name_widget in ./name.module
Implementation of hook_widget().
name_widget_settings in ./name.module
Implementation of hook_widget_settings().

File

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

Code

function _name_defaults(&$field, $key) {
  $name_info = name_field_info();
  $field[$key] = isset($field[$key]) ? (array) $field[$key] : array();
  foreach ($name_info['name'][$key] as $index => $defaults) {
    if (!isset($field[$key][$index])) {
      if (is_array($defaults)) {
        if (!array_key_exists($index, $field[$key])) {
          $field[$key][$index] = array();
        }
        $field[$key][$index] += $defaults;
      }
      else {
        $field[$key][$index] = $defaults;
      }
    }
  }
}