#Using enumerations
#Overview
An enumeration is a predefined set of values that represents a list of possible options.
Are you looking for our API Reference?
#What you can do
-
You can use enumerations to group values within a type.
-
You can use enumerations to create a list of values and add it to a model. The values can then be selected from a dropdown menu in the content creation screen.
#Create an enumeration
Create 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
+ Addnext to Enumerations on the Schema list, or the+ Add Enumerationsbutton located at the center of the screen. The New enumeration screen will display as a result. - Complete the
Display namefield with the name that will be displayed in Hygraph. TheAPI IDfield 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
Display name, which autocompletes theAPI IDfield, and then clicking+ Add. Your values will display on a list below. - Once you have added all the enumeration values, click
Add Enumerationat the bottom of the screen to finish the process.
#Use demo enumeration
Create an enumeration
- Navigate to the Schema builder.
- Click on
Add demo enumeration, located at the center of the screen. - The system will generate the demo enumeration and show you the enumeration details screen.
#Delete an enumeration
Delete an enumeration
- Navigate to the Schema builder.
- Click on the enumeration you want to delete.
- Click on the context menu to display the
Deleteoption, then click on it to delete the enumeration.
#Add an enumeration to a model
Add an enumeration to a model
- Navigate to the Schema builder.
- Click on the model you wish to add the enumeration to.
- Select the Enumeration field from the Add fields right sidebar.
- Complete the
Display namefield. This will autocomplete theAPI IDfield, but you can edit this value if you want. - Use the
Enumerationdropdown to select the enumeration you want to add to this model. - Optionally, you can also add a
Description. - This screen allows you to control different properties of your Enumeration field: you can allow multiple values, localize the field, or use it as title field, by selecting the checkboxes under the
Field optionssection of the screen. - Click
Addto save.
After an enumeration has been configured for your model, you will be able to use it in the content editor.
Use an enumeration in a content entry