Skip to content

Collection Field Types

Mohammed Alsiddeeq ahmed edited this page Mar 11, 2019 · 14 revisions

Collectionlink

Link to an existing entry from a collection.

{
  "link": "collectionName",
  "multiple": true,
  "display": "fieldName"
}

Select

Select from a predefined list of options.

{
  "options": [
    "opt1",
    "opt2",
    "opt3"
  ]
}

Set and Repeater Fields

Both accept fields option of the following format:

{
 "fields": [
	{
		"type":"text",
		"name":"myTextField",
		"label":"My Text Field"
	},
	{
		"type":"wysiwyg",
		"name":"myWYSIWYGField",
		"label":"My WYSIWYG Field"
	}
 ]
}

Set fields will render all included fields in a group. Repeater fields will offer all included fields as instantiatable members of a list.

Nested Sets Within Repeaters

A set can be used as the field type for repeater, allowing multiple sets with predefined fields to be instantiated. You can even combine the two (the following examples would go in the options block for a repeater field).

Multiple authors each with a first/middle/last name field

{
  "field": {
    "type": "set",
    "name": "author",
    "label": "Individual Author",
    "options": {
      "fields": [
        {
          "name": "first",
          "type": "text",
          "label": "First Name"
        },
        {
          "name": "middle",
          "type": "text",
          "label": "Middle"
        },
        {
          "name": "last",
          "type": "text",
          "label": "Last"
        }
      ]
    }
  }
}

Repeater with a choice between a set and WYSIWYG field

{
  "fields": [
    {
      "type":"set",
      "name":"mySetField",
      "label":"My Set Field",
      "options": {
        "fields": [
          {
            "type":"wysiwyg",
            "name":"someFieldName",
            "label":"Some Field Name"
          },{
            "type":"text",
            "name":"howAboutATextFieldWithThatWYSIWYG",
            "label":"Maybe a Header Or Something?"
          }
        ]	
      }
    },
    {
      "type":"wysiwyg",
      "name":"myWYSIWYGField",
      "label":"Sometimes Just a WYSIWYG is Enough"
    }
  ]
}

This allows you to make groups of fields available as presets in your repeater.