function content_field_instance_expand in Content Construction Kit (CCK) 6.2
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 includes/content.crud.inc \content_field_instance_expand()
Expand field info to create field => widget info.
8 calls to content_field_instance_expand()
- ContentCrudBasicTest::testBasic in tests/
content.crud.test - content_field_edit_form_validate in includes/
content.admin.inc - Validate a field's settings.
- 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.
File
- includes/
content.crud.inc, line 106 - 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;
}