You are here

function content_field_instance_collapse in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 includes/content.crud.inc \content_field_instance_collapse()
  2. 6 includes/content.crud.inc \content_field_instance_collapse()
  3. 6.2 includes/content.crud.inc \content_field_instance_collapse()

Collapse field info from field => widget to flattened form values.

1 call to content_field_instance_collapse()
content_copy_export in ./content_copy.module
Process the export, get field admin forms for all requested fields and save the form values as formatted text.

File

./content_crud.inc, line 51
Create/Read/Update/Delete functions for CCK-defined object types.

Code

function content_field_instance_collapse($field) {
  if (!isset($field['widget'])) {
    return $field;
  }
  $field['widget_settings'] = !empty($field['widget']) ? $field['widget'] : array();
  $field['widget_type'] = !empty($field['widget']['type']) ? $field['widget']['type'] : '';
  $field['weight'] = !empty($field['widget']['weight']) ? $field['widget']['weight'] : 0;
  $field['label'] = !empty($field['widget']['label']) ? $field['widget']['label'] : $field['field_name'];
  $field['description'] = !empty($field['widget']['description']) ? $field['widget']['description'] : '';
  $field['type_name'] = !empty($field['type_name']) ? $field['type_name'] : '';
  if (!empty($field['widget']['module'])) {
    $widget_module = $field['widget']['module'];
  }
  elseif (!empty($field['widget']['type'])) {
    $widget_types = _content_widget_types();
    $widget_module = $widget_types[$field['widget']['type']]['module'];
  }
  else {
    $widget_module = '';
  }
  $field['widget_module'] = $widget_module;
  unset($field['widget_settings']['type']);
  unset($field['widget_settings']['weight']);
  unset($field['widget_settings']['label']);
  unset($field['widget_settings']['description']);
  unset($field['widget_settings']['module']);
  unset($field['widget']);
  return $field;
}