1 field.info.inc _field_info_prepare_instance_widget($field, $widget)

Prepares widget specifications for the current run-time context.

Parameters

$field: The field structure for the instance.

$widget: Widget specifications as found in $instance['widget'].

Related topics

File

core/modules/field/field.info.inc, line 401
Field Info API, providing information about available fields and field types.

Code

function _field_info_prepare_instance_widget($field, $widget) {
  $field_type = field_info_field_types($field['type']);

  // Fill in default values.
  $widget += array(
    'type' => $field_type['default_widget'],
    'settings' => array(),
    'weight' => 0,
  );

  $widget_type = field_info_widget_types($widget['type']);
  // Fallback to default formatter if formatter type is not available.
  if (!$widget_type) {
    $widget['type'] = $field_type['default_widget'];
    $widget_type = field_info_widget_types($widget['type']);
  }
  $widget['module'] = $widget_type['module'];
  // Fill in default settings for the widget.
  $widget['settings'] += field_info_widget_settings($widget['type']);

  return $widget;
}