Skip to content

Installation Guide

This guide covers installing and enabling the Primary Entity Reference module.

Requirements

Before installing, ensure your site meets these requirements:

  • Drupal Core: 11.1 or higher
  • PHP: 8.3 or higher
  • Optional: Inline Entity Form module (only required if you want to use the Inline Form widget)

The recommended way to install the module is using Composer:

Step 1: Download the Module

Open your terminal and navigate to your Drupal root directory, then run:

composer require drupal/primary_entity_reference

This will download the module and all its dependencies.

Step 2: Enable the Module

Enable the module using Drush:

drush en primary_entity_reference

Or enable it through the Drupal admin interface:

  1. Navigate to Extend (/admin/modules)
  2. Find Primary Entity Reference in the module list (under "Field types")
  3. Check the box next to the module name
  4. Scroll down and click Install

Step 3: Clear Cache

Clear your site's cache to ensure all changes take effect:

drush cr

Or through the admin interface:

  1. Navigate to Configuration → Development → Performance (/admin/config/development/performance)
  2. Click Clear all caches

Optional: Install Inline Entity Form

If you want to use the Inline Form widget to create and edit entities directly within the field, you'll need to install the Inline Entity Form module:

composer require drupal/inline_entity_form
drush en inline_entity_form

Without this module, the Inline Form widget option will not be available, but the other two widgets (Autocomplete and Check boxes/radio buttons) will work fine.

If you cannot use Composer, you can install manually:

  1. Download the module from the project page
  2. Extract the files to your /modules directory (or /modules/contrib)
  3. Follow steps 2-3 from the Composer installation above

Note: Manual installation does not handle dependencies automatically. You'll need to manually install any required modules.

Verifying Installation

To verify the module is installed correctly:

Check the Module is Enabled

  1. Navigate to Extend (/admin/modules)
  2. Search for "Primary Entity Reference"
  3. Verify it shows as enabled (checkbox is checked and disabled)

Check the Field Type is Available

  1. Navigate to Structure → Content types → [Any content type] → Manage fields
  2. Click Add field
  3. In the field type dropdown, look for Reference → Primary entity reference

If you see the field type, the module is installed correctly!

Post-Installation Steps

Now that the module is installed, you can:

  1. Add a primary entity reference field to a content type
  2. See the Configuration Guide for detailed instructions

  3. Configure field display settings

  4. See the Formatters Guide for display options

  5. Choose and configure a widget

  6. See the Widgets Guide for input options

Uninstalling the Module

To uninstall the module:

Step 1: Remove All Fields

Before uninstalling, you must remove all primary entity reference fields from your site:

  1. Navigate to each content type that uses the field
  2. Go to Manage fields
  3. Delete any fields with type "Primary entity reference"

Step 2: Uninstall the Module

Using Drush:

drush pmu primary_entity_reference

Or through the admin interface:

  1. Navigate to Extend → Uninstall (/admin/modules/uninstall)
  2. Find Primary Entity Reference
  3. Check the box next to it
  4. Click Uninstall
  5. Confirm the uninstallation

Warning: Uninstalling will permanently delete all data stored in primary entity reference fields.

Next Steps