Group field doesn't seem to work

I've looked at the documentation for Group fields, but for some reason, they just don't seem to work at all. When I drag the group field/slice into the Prismic editor, the sections just stay blank, with no field added.

Is there some sort of prerequisite to use fields? Or is this a known bug.

Ok, so I went into the JSON editor to manually add groups - and it turns out that for some reason, I can’t nest groups inside slices.

I’m not sure how much of a stretch it would be to enable that, but it would super helpful.

Hello David!

Group fields cannot be added into Slices. Instead you add fields into the Repeatable Zone of a Slice this section works in a similar way as the Group field. The difference will be in the response object structure.

So if you access to a group field like this: document.data.group_content
In a slice you’ll find the elements in the items array of objects. It’ll be something like this:

    if{document.data.slice.slice_type === 'group_content_slice' {
        return slice.items.map(item => { ... })}

Learn more about Slices

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.