function _content_field_write in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 includes/content.crud.inc \_content_field_write()
- 6 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 398 - 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 = (array) module_invoke($field['module'], 'field_settings', 'save', $field);
drupal_alter('field_settings', $setting_names, 'save', $field);
foreach ($setting_names as $setting) {
// Unlike _content_field_instance_write() and 'widget_settings', 'global_settings'
// is never preexisting, so we take no particular precautions here.
$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;
}