function content_field_instance_expand in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 includes/content.crud.inc \content_field_instance_expand()
- 6 includes/content.crud.inc \content_field_instance_expand()
- 6.2 includes/content.crud.inc \content_field_instance_expand()
Expand field info to create field => widget info.
File
- ./
content_crud.inc, line 11 - Create/Read/Update/Delete functions for CCK-defined object types.
Code
function content_field_instance_expand($field) {
if (isset($field['widget'])) {
return $field;
}
$field['widget'] = !empty($field['widget_settings']) ? $field['widget_settings'] : array();
$field['widget']['label'] = !empty($field['label']) ? $field['label'] : $field['field_name'];
$field['widget']['weight'] = !empty($field['weight']) ? $field['weight'] : 0;
$field['widget']['description'] = !empty($field['description']) ? $field['description'] : '';
if (!empty($field['widget_type'])) {
$field['widget']['type'] = $field['widget_type'];
$widget_types = _content_widget_types();
$field['widget']['module'] = isset($widget_types[$field['widget_type']]['module']) ? $widget_types[$field['widget_type']]['module'] : $field['widget_module'];
}
elseif (!empty($field['widget_module'])) {
$field['widget']['module'] = $field['widget_module'];
}
unset($field['widget_type']);
unset($field['weight']);
unset($field['label']);
unset($field['description']);
unset($field['widget_module']);
unset($field['widget_settings']);
// If content.module is handling the default value,
// initialize $widget_settings with default values,
if (isset($field['default_value']) && isset($field['default_value_php']) && content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_DEFAULT) {
$field['widget']['default_value'] = !empty($field['default_value']) ? $field['default_value'] : NULL;
$field['widget']['default_value_php'] = !empty($field['default_value_php']) ? $field['default_value_php'] : NULL;
unset($field['default_value']);
unset($field['default_value_php']);
}
return $field;
}