You are here

function content_field_default_values in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 6.3 includes/content.crud.inc \content_field_default_values()
  2. 6.2 includes/content.crud.inc \content_field_default_values()

Create an array of default values for a field type.

1 call to content_field_default_values()
content_field_instance_create in includes/content.crud.inc
Create a new field instance.

File

includes/content.crud.inc, line 30
Create/Read/Update/Delete functions for CCK-defined object types.

Code

function content_field_default_values($field_type) {
  $field_types = _content_field_types();
  $module = $field_types[$field_type]['module'];
  $field = array(
    'module' => $module,
    'type' => $field_type,
    'active' => 0,
  );
  if (module_exists($module)) {
    $field['active'] = 1;
  }
  $field['columns'] = module_invoke($module, 'field_settings', 'database columns', $field);

  // Ensure columns always default to NULL values.
  foreach ((array) $field['columns'] as $column_name => $column) {
    $field['columns'][$column_name]['not null'] = FALSE;
  }
  $field['required'] = 0;
  $field['multiple'] = 0;
  $field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE;

  // Make sure field settings all have an index in the array.
  $setting_names = module_invoke($module, 'field_settings', 'save', $field);
  if (is_array($setting_names)) {
    foreach ($setting_names as $setting) {
      $field[$setting] = NULL;
    }
  }
  return $field;
}