You are here

function editablefields_fallback_formatter in Editable Fields 7

Format a field using the fallback formatter of the editable field.

1 call to editablefields_fallback_formatter()
editablefields_field_formatter_view in ./editablefields.module
Implements hook_field_formatter_view().
1 string reference to 'editablefields_fallback_formatter'
editablefields_lazy_render_fields in ./editablefields.module
#pre-render function: render the fallback formatter of a field, but only if it is actually displayed.

File

./editablefields.module, line 208
Editable fields module.

Code

function editablefields_fallback_formatter($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  // Set the fallback formatter.
  $display['type'] = $display['settings']['fallback_format'];
  $display['settings'] = $display['settings']['fallback_settings'];
  $formatter_type = field_info_formatter_types($display['type']);
  if (isset($formatter_type['module'])) {
    $display['module'] = $formatter_type['module'];
  }
  else {
    return;
  }

  // Clone the entity to avoid messing with it.
  $cloned_entity = clone $entity;
  return field_view_field($entity_type, $cloned_entity, $field['field_name'], $display, $langcode);
}