You are here

function _content_field_instance_write in Content Construction Kit (CCK) 6

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

Write a field instance record.

Parameters

$field: The field array to process.

2 calls to _content_field_instance_write()
content_field_instance_create in includes/content.crud.inc
Create a new field instance.
content_field_instance_update in includes/content.crud.inc
Update an existing field instance.

File

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

Code

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

  // Collapse the field => widget format.
  $field = content_field_instance_collapse($field);

  // Rearrange the data to create the widget_settings array.
  $setting_names = module_invoke($field['widget_module'], 'widget_settings', 'save', $field);
  if (is_array($setting_names)) {
    foreach ($setting_names as $setting) {
      $field['widget_settings'][$setting] = isset($field[$setting]) ? $field[$setting] : '';
      unset($field[$setting]);
    }
  }
  switch ($op) {
    case 'create':
      drupal_write_record(content_instance_tablename(), $field);
      break;
    case 'update':
      drupal_write_record(content_instance_tablename(), $field, array(
        'field_name',
        'type_name',
      ));
      break;
  }
  return $field;
}