Using enumerations
#Overview
An enumeration is a predefined set of values that represents a list of possible options.
#What you can do
-
You can use enumerations to group values within a type.
-
You can use enumerations to create a list of values, which can then be used when adding a Dropdown field to your models.
#Create an enumeration
Navigate to the Schema builder. On the screen, you can add an enumeration or use a demo one. We will show you both procedures.
Create an enumeration
#Add an enumeration
- Navigate to the Schema builder
- You can create an enumeration by navigating to the Schema builder, locating enumerations on the Schema list, and then clicking on
+ Add
next to Enumerations on the Schema list, or the+ Add Enumerations
button located at the center of the screen. The Add enumeration screen will display as a result. - Complete the
Display name
field with the name that will be displayed in Hygraph. TheAPI ID
field will be autocompleted when you complete theDisplay name
, but you can edit this value. The API ID is the ID for accessing this enumeration through the API. - Optionally, you can add a
Description
. - Under enumeration values, you can add a list of values by manually entering the value names in the text field and then clicking on the
+ Add to list
button. - Once you have added all the enumeration values, click on the
Add Enumeration
button at the bottom of the screen to finish the process.
#Use demo enumeration
- Navigate to the Schema builder.
- Click on the
Use demo enumeration
button, located at the center of the screen. The demo enumeration will be autogenerated as a result. - The enumeration details screen will be displayed, where all the data will already be complete. You can edit this information.
#Delete an enumeration
- Navigate to the Schema builder.
- Click on the enumeration you want to delete.
- Click on the three dots icon to display the
Delete
option, then click on it to delete the enumeration.
#Use an enumeration in a model
- Navigate to the Schema builder.
- Click on the model you wish to add the enumeration to.
- Select the Dropdown field under Enumerations from the Add fields right sidebar.
- Complete the
Display name
field, and theAPI ID
will be auto-filled by the system. - Use the
Enumerations
dropdown to select the enumeration you wish to add to this model. - Optionally, you can also add a
Description
. - This screen allows you to control different properties of your Dropdown field: you can allow multiple values, localize the field, or use it as title field, by selecting the checkboxes under the
Field options
section of the screen. - Click on the
Add
button. Your dropdown field will be added on the model as a result.
After an enumeration has been configured for your model, you will be able to use the dropdown in the content editor.
Use an enumeration in a content entry