Primary Entity Reference is a field type that extends the standard Entity Reference field with the ability to mark one referenced entity as the primary.
This is useful for content types where you want to reference multiple entities but always need one of them to be considered the “main” or “default” — for example:
- Setting an Address as primary.
- Highlighting the primary author among multiple contributors.
- Marking the featured image out of a gallery.
- Defining a main contact from a list of people.
Features 🔧
- Provides a custom field type that stores multiple entity references, with one marked as primary.
- Ensures exactly one referenced entity is always primary.
- If only one value exists, it is automatically treated as primary.
- Includes a widget for selecting the primary item inline.
- Includes a formatter that displays only the primary entity.
- Fully compatible with Drupal’s Field API.
Integration
Projects that use Primary Entity Reference
Development ⚙
git clone git@git.drupal.org:project/primary_entity_reference.git cd primary_entity_reference ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=primary-entity-reference ddev add-on get ddev/ddev-drupal-contrib ddev add-on get ddev/ddev-selenium-standalone-chrome ddev start ddev poser ddev symlink-project ddev drush site:install -y ddev drush pm:install primary_entity_reference -y ddev drush config:export -y ddev drush user:login
Supporting organizations:
Project information
- Project categories: Content display, Content editing experience
66 sites report using this module
- Created by bluegeek9 on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
1.0.0-beta7
released 15 February 2026
Works with Drupal: >=11.1
Install:
Development version: 1.0.x-dev updated 5 Feb 2026 at 19:01 UTC
