Wigandt Technology

Directus Polymorphic Reference

Directus interface and display bundle for polymorphic references, resolving collection and ID pairs into navigable templated links.

Project overview

Directus Polymorphic Reference models flexible relations where a record points to different entity types through a target collection and target ID. The pattern is similar to polymorphic relations known from frameworks such as Laravel and makes it usable in Directus through an interface and display bundle.

The extension stores the target collection and target ID in separate fields, while presenting them as one understandable reference in the interface. Editors first choose the entity type and then select the matching record.

For list and detail views, output can be shaped through templates. Polymorphic references appear as readable, navigable links instead of raw IDs.

What the extension covers

Collection Select interface for the type field of a polymorphic reference

Polymorphic Reference interface for selecting the target record

Display component with links into the matching Directus collection

Template-based labels per target collection for readable list views

Setup and usage

  1. 1Configure one field for the target type as Collection Select.
  2. 2Configure one field for the target ID as Polymorphic Reference.
  3. 3Optionally define templates and link behavior per collection.

Screenshots

Data model of a polymorphic Directus reference
Data model with type field and target ID.
Setup flow of the Polymorphic Reference extension
Flow for collection selection, reference field and display.
Field states of Directus Polymorphic Reference
Field states for selection, display and empty references.
DirectusRelationsnpm