Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Composite Reference

314 sites Security covered Drupal 10–11
View on drupal.org

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.

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
3
Tracked since
Jan 2025
Latest release
9 months ago
Releases (12 mo)
1 ▼ from 2
Maintenance
Active

Release Timeline

Releases

Version Type Core 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