public function FieldInfo::prepareInstanceWidget in Drupal 7
Prepares widget properties for the current run-time context.
Parameters
$widget: Widget specifications as found in $instance['widget'].
$field_type: The field type.
Return value
The widget properties completed for the current runtime context.
1 call to FieldInfo::prepareInstanceWidget()
- FieldInfo::prepareInstance in modules/
field/ field.info.class.inc - Prepares an instance definition for the current run-time context.
File
- modules/
field/ field.info.class.inc, line 575
Class
- FieldInfo
- Provides field and instance definitions for the current runtime environment.
Code
public function prepareInstanceWidget($widget, $field_type) {
$field_type_info = field_info_field_types($field_type);
// Fill in default values.
$widget += array(
'type' => $field_type_info['default_widget'],
'settings' => array(),
'weight' => 0,
);
$widget_type_info = field_info_widget_types($widget['type']);
// Fall back to default formatter if formatter type is not available.
if (!$widget_type_info) {
$widget['type'] = $field_type_info['default_widget'];
$widget_type_info = field_info_widget_types($widget['type']);
}
$widget['module'] = $widget_type_info['module'];
// Fill in default settings for the widget.
$widget['settings'] += field_info_widget_settings($widget['type']);
return $widget;
}