跳到主要内容

Managing relational fields

Relation-type fields added to a content-type from the Content-type Builder allow establishing a relation with another collection type. These fields are called "relational fields".

The content of relational fields is written from the edit view of the content-type they belong to (see Writing content). However, relational fields can point to one or several entries of the other collection type, this is why in the Content Manager it is possible to manage a content-type's relational fields to choose which entries are relevant.

Example

In my Strapi admin panel I have created 2 collection types:

  • Restaurant, where each entry is a restaurant
  • Category, where each entry is a type of restaurant

I want to assign a category to each of my restaurants, therefore I have established a relation between my 2 collection types: restaurants can have one category.

In the Content Manager, from the edit view of my Restaurant entries, I can manage the Category relational field, and choose which entry of Category is relevant for my restaurant.

Relational fields in the edit viewRelational fields in the edit view

The relational fields of a content-type are displayed among regular fields. For each relational field is displayed a drop-down list containing all available entry titles. It allows to choose which entry the relational fields should point to. You can either choose one or several entries depending on the type of relation that was established.

💡 Tip

Not all entries are listed by default: more can be displayed by clicking on the Load more button. Also, instead of choosing an entry by scrolling the list, you can click any relational field drop-down list and type to search a specific entry.

✏️ Note

If the Draft & Publish feature (see Saving, publishing and deleting content) is activated for the content-type the relational field belongs to, you will notice blue or green dots next to the entries names in the drop-down list. They indicate the status of the entry, respectively draft or published content.

Caution

If the Internationalization plugin is installed, the list of entries may be limited or differ from one locale to another. Only relevant entries that can possibly be chosen for a relational field will be listed.

Managing one-choice relational fields

Many-to-one, one-to-one, and one-way types of relation only allow to choose one entry per relational field.

One-choice relational fieldsOne-choice relational fields

To select the only relevant relational field's entry:

  1. In the content-type's edit view, click on the drop-down list of the relational field.
  2. Among the list of entries, choose one.
💡 Tip

You can click on the name of the selected entry to be redirected to the edit view of the relational field's content type. Make sure you save your page first, to avoid losing your last modifications.

To remove the entry selected in the drop-down list, click on the delete button Clear icon.

Managing multiple-choice relational fields

Many-to-many, one-to-many, and many-ways types of relation allow to choose several entries per relational field.

Multiple choices relational fieldsMultiple choices relational fields

To select the relevant relational field's entries:

  1. In the content-type's edit view, click on the drop-down list of the relational field.
  2. Among the list of entries, choose one.
  3. Repeat step 2 until all relevant entries have been chosen.
💡 Tip

All selected entries are listed right below the drop-down list. Click on the name of an entry to be redirected to the edit view of the relational field's content-type. Make sure you save your page first, to avoid losing your last modifications.

To remove an entry, click on the cross button Cross icon in the selected entries list.

Entries from multiple-choice relational fields can be reordered, indicated by a drag button Drag icon. To move an entry, click and hold it, drag it to the desired position, then release it.