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)
Installation via Composer (Recommended)
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:
- Navigate to Extend (
/admin/modules) - Find Primary Entity Reference in the module list (under "Field types")
- Check the box next to the module name
- 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:
- Navigate to Configuration → Development → Performance (
/admin/config/development/performance) - 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.
Manual Installation (Not Recommended)
If you cannot use Composer, you can install manually:
- Download the module from the project page
- Extract the files to your
/modulesdirectory (or/modules/contrib) - 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
- Navigate to Extend (
/admin/modules) - Search for "Primary Entity Reference"
- Verify it shows as enabled (checkbox is checked and disabled)
Check the Field Type is Available
- Navigate to Structure → Content types → [Any content type] → Manage fields
- Click Add field
- 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:
- Add a primary entity reference field to a content type
-
See the Configuration Guide for detailed instructions
-
Configure field display settings
-
See the Formatters Guide for display options
-
Choose and configure a widget
- 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:
- Navigate to each content type that uses the field
- Go to Manage fields
- 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:
- Navigate to Extend → Uninstall (
/admin/modules/uninstall) - Find Primary Entity Reference
- Check the box next to it
- Click Uninstall
- Confirm the uninstallation
Warning: Uninstalling will permanently delete all data stored in primary entity reference fields.
Next Steps
- Configuration Guide - Learn how to add the field to content types
- Widgets Guide - Choose the best widget for your use case
- Usage Examples - See real-world examples