primary_entity_reference
88 sites
Security covered
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 [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 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