Object Field Type

Additional attributes, defaults, and usage example for object fields.

Control Type
Object preview with controls to open the editor for the object, along with the ability to add and remove the object.
Stored Value
An object embedded within the parent object.
Supported Sources
Only works with content sources that allow for embedding objects within their parents.

Usage Example

Here is an example that shows a featuredSection field, where the object inside has heading and backgroundImage fields.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
export default {
  objects: {
    Page: {
      fields: [
        { name: 'title', type: 'string', required: true },
        {
          name: 'featuredSection',
          type: 'object',
          fields: [
            {
              name: 'heading',
              type: 'string',
            },
            {
              name: 'backgroundImage',
              type: 'image',
            },
          ],
        },
      ],
    },
  },
}

This will render a preview of the embedded object, with support for adding, editing, and removing.

Object Preview Field Control
Object Preview Field Control

Clicking on the preview will drill down in to the editor for that embedded object.

Embedded Object Editor
Embedded Object Editor

Required Properties

Object fields require that you specify one or more field definitions for the object, using the fields property.

fields
An array of field definitions for the object, using any desired field.

Similarities to Other Objects

Object fields are similar to reference and model fields, with key differences for each scenario.

Reference vs Object

reference fields refer to a page model (rather than an object model). They don't embed the result, but store a reference to that result. (As a string for Git CMS, and a built-in reference for API CMS.)

Model vs Object

model fields are stored in the same way as object fields, but they use field definitions described in other models. They also support allowing a choice between multiple types.