Relationship Field

A relationship field allows to connect one table to another. For example, in a recruitment app, having the tables jobApplications, applicants and positions, we can have the job applications connected to an applicant and a position:

Relationship field example diagram

We can implement this structure using relationship fields:

key: jobApplications
type: table
name: Job Applications
itemName: Job Application

summary:
  title: "Candidate {{candidate.firstName}} {{candidate.lastName}} applying to {{role.name}} position"

fields:
  applicant:
    type: relationship
    table: applicants
    label: Applicant
  position:
    type: relationship
    table: positions
    label: Position
  date:
    type: date
    label: Application Date

For this code to work, you need to have the applicants and positions tables defined as well. You only need to define the relationship field in the parent table, you don’t need to add anything on the child tables.

The form for creating a new job application will be presented like this:

Relationship field example form

More information in the YAML reference documentation.