Structure field with another structure field inside?

…

sections:
    label: Sections
    type: structure
    fields:
      text:
        label: Text 1
        type: text
      subsections:
        label: Subsections
        type: structure
        fields:
          text:
            label: Text 2
            type: text

…

I’m having an error in: The field could not be found in …/panel/app/controllers/views/editor.php on Line 60.

That’s not possible, as structure fields use modals and putting modals on top of modals is a UX disaster. Making nested structure fields possible will require designing a new/better user interface for them as Bastian wrote on GitHub.

3 Likes

A popular workaround to this problem is to create a special page type or “blueprint” that restricts the possible child pages’ templates. This way, you can add pseudo-children to the page that in turn contain structure fields.

Imagine a content folder structure like this:

/home/home.txt
/special-page/special.txt
/special-page/subpage-1/subpage-type-one.txt
/special-page/subpage-2/subpage-type-two.txt
/special-page/subpage-3/subpage-type-one.txt
/special-page/subpage-4/subpage-type-three.txt

The special template/blueprint dictates which page templates can be used beneath it:

pages:
  templates:
    - subpage-type-one
    - subpage-type-two
    - subpage-type-three

The blueprints for each of the subpage-type-* pages would include what you’ve described as a “nested structure field,” but because these are discrete pages, now, they can be added as normal structure fields. You could very well only have a single sub-page type, but the idea here is that you can create a flexible system of nested data structures.

2 Likes

Thanks! That’s exactly I’ve done time ago with Kirby 1 :smile:, but it’s was a little confusing for client…

You’re right, I hope some day it be possible to have something similar to the WordPress ACF plugin…

1 Like