Grouping, or "nesting" fields inside an object

In Prismic, I know that "type" : "Group" can be used to nest a repeatable group of fields. Is there a way to nest a non-repeatable group of fields? For example, let's say I'm creating a test with 10 repeating questions, but I only need to allow for one essay. Consider the example below:

"Test": {
	// Questions can be repeatable
	"questions" : {
		"type" : "Group",
		"config" : {
			"label": "Questions",
			"fields": {
				"question": {},
				"answer": {}
			}
		}
	},
	// Essay should not be repeatable, only allow 1 a
	"essay" : {
		"type": "???", // <- What type do I use here?
		"config": {
			"label": "Essay",
			"fields": {
				"prompt": {},
				"help-text": {}
			}
		}
	}
}

When I access data.questions I'll get an array of questions, but how can I make it so data.essay only gives me a single object, instead of an array of them? Is there a way to achieve this either through the "Build mode", or JSON editor?

Hi there,

Welcome to the Prismic community.

I will gather some information and do some tests and get back to you.

In fact, for such a use case we recommend using slices as it gives more flexibility.

Can you explain how different is Q&A (FAQ) from what you are trying to achieve?

Best,
Fares

Hi @marco2,

Sorry for the delay,

In fact, you need to set the key config.repeat to false if you don't want the group field to be repeatable.

For more info please check this article.

Please let me know if you need more info,
Fares

1 Like

This thread has been closed due to inactivity. Flag to reopen.

Hi @Fares,

When I use config.false, the UI on document screen hides the button to "add" a new row, which means I cannot add even a single row of fields. Unless I'm missing something?

Hi Jordan,

Well, it depends on your use case, this thread is actually about adding a nonrepeatable group field, is that is what you are looking for?