Column Types: Reference Fields
When to Use
Referencing other entities (nodes, taxonomy terms, users, media) from custom field columns.
entity_reference
Reference to any entity type.
| Setting | Type | Default | Notes |
|---|---|---|---|
| target_type | string | NULL | Entity type ID (node, taxonomy_term, user, media, etc.) |
Schema: INT UNSIGNED NOT NULL DEFAULT 0 (stores target entity ID)
columns:
category:
name: category
type: entity_reference
target_type: taxonomy_term
author:
name: author
type: entity_reference
target_type: user
Gotchas: target_type required and locked after data exists. Only entity types with ID key allowed. No bundle filtering at storage level -- use widget settings for that.
Common Mistakes
- Not setting target_type -- Required field; entity_reference won't save without it
- Trying to change target_type after data -- Locked once data exists; requires field recreation
- Forgetting access checks -- Entity references don't auto-check access; validate in widget and check in formatter
- Not configuring widget handler settings -- Use EntityReferenceAutocompleteWidget or EntityReferenceSelectWidget settings to filter by bundle, sort, etc.
See Also
- Column Types: Date/Time Fields
- Column Types: File Fields
- Entity Reference Sub-Fields -- widget selection and access-check patterns