0

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" : {
        "type" : "Group",
        "config" : {
            "label": "Questions",
            "fields": {
                "question": {},
                "answer": {}
            }
        }
    },
    "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?

M -
  • 26,908
  • 11
  • 49
  • 81
  • Hey there, unfortunately, there's no way to group fields this way. You can try prefixing each field id meant to be grouped and then look for fields starting with this prefix on your document data once in the code. – lihbr Aug 13 '21 at 08:21
  • @lihbr Thanks for confirming my suspicions. It would be nice to have a non-repeating group to simply access `data.essay`. – M - Aug 13 '21 at 17:51
  • For sure! Will forward this feedback to our product team – lihbr Aug 15 '21 at 12:09

0 Answers0