1 file.module | file_file_formatter_file_field_settings($form, &$form_state, $settings, $formatter_type, $file_type, $view_mode) |
Implements hook_file_formatter_FORMATTER_settings().
This function provides a bridge to the field formatter API, so that file field formatters can be reused for displaying the file entity's file pseudo-field.
File
- core/
modules/ file/ file.module, line 696 - Defines a "managed_file" Form API field and a "file" field for Field module.
Code
function file_file_formatter_file_field_settings($form, &$form_state, $settings, $formatter_type, $file_type, $view_mode) {
if (strpos($formatter_type, 'file_field_') === 0) {
$field_formatter_type = substr($formatter_type, strlen('file_field_'));
$field_formatter_info = field_info_formatter_types($field_formatter_type);
// Invoke hook_field_formatter_settings_form(). We are reusing field
// formatter functions, but we are not working with a Field API field, so
// set $field accordingly. Unfortunately, the API is for $settings to be
// transferred via the $instance parameter, so we must mock it.
if (isset($field_formatter_info['module']) && ($function = ($field_formatter_info['module'] . '_field_formatter_settings_form')) && function_exists($function)) {
$field = NULL;
$mock_instance = array(
'display' => array(
$view_mode => array(
'type' => $field_formatter_type,
'settings' => $settings,
),
),
'entity_type' => 'file',
'bundle' => $file_type,
);
return $function($field, $mock_instance, $view_mode, $form, $form_state);
}
}
}