You are here

function _content_field_write in Content Construction Kit (CCK) 6

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

Write a field record.

Parameters

$field: The field array to process.

3 calls to _content_field_write()
content_field_instance_create in includes/content.crud.inc
Create a new field instance.
content_field_instance_delete in includes/content.crud.inc
Delete an existing field instance.
content_field_instance_update in includes/content.crud.inc
Update an existing field instance.

File

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

Code

function _content_field_write($field, $op = 'update') {

  // Rearrange the data to create the global_settings array.
  $field['global_settings'] = array();
  $setting_names = module_invoke($field['module'], 'field_settings', 'save', $field);
  if (is_array($setting_names)) {
    foreach ($setting_names as $setting) {
      $field['global_settings'][$setting] = isset($field[$setting]) ? $field[$setting] : '';
      unset($field[$setting]);
    }
  }

  // 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'.
  $field['db_columns'] = $field['columns'];
  switch ($op) {
    case 'create':
      drupal_write_record(content_field_tablename(), $field);
      break;
    case 'update':
      drupal_write_record(content_field_tablename(), $field, 'field_name');
      break;
  }
  unset($field['db_columns']);
  return $field;
}