createdBy and updatedBy; see Default fields.
Set type to relationship and provide the target collection slug in relationTo:
Config options
Admin options
Theadmin option inherits the standard field admin options and adds settings specific to relationships:
Sort options
Provide a field name to sort every target collection the same way. Prefix it with- for descending order:
sortOptions, the selector uses its default ordering.
Filtering relationship options
UsefilterOptions to limit records in the selector and validate submitted relationships. It accepts a query constraint, or a callback that returns a constraint, true to allow every record, or false to allow none.
The callback receives:
The callback can return a different constraint for each target collection:
Bidirectional relationships
A Relationship field stores the connection on the record containing it. The related record does not automatically receive a reverse list. Add a Join field to the related collection when editors or API consumers need to traverse the relationship in both directions.Stored data
The stored shape depends on whether the field accepts one or many records and one or many collection types.Has one
A relationship to one collection stores the related record ID:Has one, polymorphic
An array inrelationTo allows one record from any listed collection:
value, or query the target collection through relationTo:
Has many
SethasMany to store an array of IDs from one collection:
Has many, polymorphic
Combine an array inrelationTo with hasMany:
.value path as a polymorphic has-one field:
Querying and filtering polymorphic relationships
Polymorphic values always identify both the target collection inrelationTo and the related record in value. Their storage differs from non-polymorphic relationships, so list-view filtering is limited to the related ID.
Filter by related record ID:
Linking virtual fields with relationships
A virtual field can expose data from a populated relationship without storing another database value. Setvirtual to the relationship path that leads to the value.
Custom components
Override the field or its label throughadmin.components. Custom components can wrap FrogBot’s default relationship controls.