function content_field_instance_expand in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 5 content_crud.inc \content_field_instance_expand()
- 6.3 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.
4 calls to content_field_instance_expand()
- content_field_instance_create in includes/
content.crud.inc - Create a new field instance.
- content_field_instance_read in includes/
content.crud.inc - Load a field instance.
- content_field_instance_update in includes/
content.crud.inc - Update an existing field instance.
- _content_admin_field_validate in includes/
content.admin.inc - Validate a field's settings.
File
- includes/
content.crud.inc, line 105 - 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'] : NULL;
$field['widget']['description'] = !empty($field['description']) ? $field['description'] : NULL;
if (!empty($field['widget_type'])) {
$field['widget']['type'] = $field['widget_type'];
$widget_types = _content_widget_types();
$field['widget']['module'] = $widget_types[$field['widget_type']]['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;
}