Primary Entity Reference
This module adds a field type that allows you to reference multiple entities while designating one as primary. It ensures exactly one entity is always marked as the primary reference.
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 ⚙
If you haven't already, install DDEV.
git clone [email protected]: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 s-ayers/ddev-drupal-contrib-mkdocs ddev add-on get s-ayers/ddev-drupal-paratest 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
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta8 | Pre-release | 11 | Aug 4, 2026 | ||
| 1.0.0-beta7 | Pre-release | 11 | Feb 15, 2026 | ||
| 1.0.0-beta6 | Pre-release | 11 | Normalizer service | Feb 2, 2026 | |
| 1.0.0-beta5 | Pre-release | 11 | Jan 30, 2026 | ||
| 1.0.0-beta4 | Pre-release | 11 | Jan 29, 2026 | ||
| 1.0.0-beta3 | Pre-release | 11 | Jan 27, 2026 | ||
| 1.0.0-beta2 | Pre-release | 11 | Jan 18, 2026 | ||
| 1.0.0-beta1 | Pre-release | 11 | Dec 22, 2025 | ||
| 1.0.0-alpha3 | Pre-release | 11 | Dec 12, 2025 | ||
| 1.0.0-alpha2 | Pre-release | 11 | Oct 23, 2025 | ||
| 1.0.0-alpha1 | Pre-release | 11 | first release | Oct 23, 2025 | |
| 1.0.x-dev | Dev | 11 | May 17, 2025 |