function cck_field_set_setting in Content Construction Kit (CCK) 7.3
Helper function to set field settings stored by CCK.
CCK uses the 'cck_field_settings' table to store custom settings not used by core.
Field settings will have no $instance nor a db bundle column.
4 calls to cck_field_set_setting()
- cck_allowed_values_validate in ./
cck.module - Validation handler to store php allowed values.
- cck_content_migrate_field_alter in ./
cck.module - Implements hook_content_migrate_field_alter().
- cck_content_migrate_instance_alter in ./
cck.module - Implements hook_content_migrate_instance_alter().
- cck_default_value_validate in ./
cck.module - Validation handler to store php default values.
File
- ./
cck.module, line 244 - Allows administrators to use php code snippets to define allowed values or default values. The snippets are stored in a database table and retrieved in callback functions.
Code
function cck_field_set_setting($setting, $setting_type, $value, $field, $instance = NULL, $langcode = LANGUAGE_NONE) {
// Delete any prior values.
$bundle = $setting_type == 'field' || empty($instance) ? NULL : $instance['bundle'];
$entity_type = $setting_type == 'field' || empty($instance) ? NULL : $instance['entity_type'];
if ($setting_type == 'field' || empty($instance)) {
db_delete('cck_field_settings')
->condition('field_name', $field['field_name'])
->condition('setting', $setting)
->condition('setting_type', $setting_type)
->execute();
}
else {
db_delete('cck_field_settings')
->condition('field_name', $field['field_name'])
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->condition('language', $langcode)
->condition('setting', $setting)
->condition('setting_type', $setting_type)
->execute();
}
// Create the new values.
if (in_array($setting, cck_serialized_settings())) {
$value = serialize($value);
}
$record = array(
'field_name' => $field['field_name'],
'entity_type' => $entity_type,
'bundle' => $bundle,
'language' => $langcode,
'setting' => $setting,
'setting_option' => $value,
'setting_type' => $setting_type,
);
$primary_keys = array();
drupal_write_record('cck_field_settings', $record, $primary_keys);
}