Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Composite Reference

Security covered Under active development 349 sites

This module makes entity reference fields "composite," meaning the referenced entities are automatically deleted when the item referencing them is deleted. This is useful for ensuring data cleanup, but should typically be used for entities that are only referenced once.

The Composite Reference module allows users to mark entity reference fields as composite.

Composite reference fields ensure that referenced entities get deleted when the referencing entity is deleted.

The deletion is prevented if the referenced entity is referenced by another entity but typically you should ensure you only use this capability for entities that can be referenced only once.

How to

The module works with both Entity Reference and Entity Reference Revisions field types.

Field configs

For configurable (bundle) fields, edit the field configuration and check the box to mark the reference as composite. The rest is taken care of.

Base fields

For base fields, simply set a custom field setting on the entity reference or entity reference revision field definition, like so:

$fields['my_field'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('My reference'))
  ->setSettings([
    'target_type' => 'node',
    'composite_reference' => TRUE,
  ]);

If the base field gets overridden, this setting will get exported to the third party setting and it will continue to work.

Drupal 10–11

Ask your assistant about Composite Reference

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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

Tracked releases
7
Tracked since
Feb 2023
Latest release
10 months ago
Releases (12 mo)
1 ▼ from 2
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.4.x-dev Dev 10–11 Nov 20, 2025
2.4.0 Stable 10–11 Feb 17, 2025
2.3.1 Stable 10 Jan 10, 2025
2.3.0 Stable 10 PHP >=8.1 Feb 16, 2024
2.2.x-dev Dev 9 PHP >=7.4 Feb 23, 2023
2.3.x-dev Dev 10 PHP >=8.1 Feb 23, 2023
2.2.0 Stable 9–10 PHP >=8.0 Feb 23, 2023