Problem/Motivation
There are many modules that provide Field Formatter and Field Widget plugins for core Entity Reference fields, but they don't support Primary Entity Reference fields because they explicitly specify the "entity_reference" field type ID.
Steps to reproduce
Proposed resolution
Implement alter hooks to insert ourselves.
This is the approach taken by the Group module, which we could easily adapt:
/**
* Implements hook_field_formatter_info_alter().
*/
function primary_entity_reference_field_formatter_info_alter(array &$info) {
// Anything that supports entity reference fields should also work for ours.
foreach ($info as $key => $formatter_info) {
if (in_array('entity_reference', $formatter_info['field_types'], TRUE)) {
$info[$key]['field_types'][] = 'primary_entity_reference';
}
}
}
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
bluegeek9 commentedField Widgets can mishandle the primary part of the field. Limiting it Field Formatters is a safer change.
Comment #5
bluegeek9 commented