Trying to get relation widget to work with file in nested collection

Hi all,

I’m struggling to get the relation widget to work for a list of authors that’s kept in a YAML file in a “Settings” collection, similar to the setup here:

I’ll post what I have, it looks very similar to the config.yml above since that’s how I’ve been doing dev & test locally:

  - name: 'faq' 
    label: 'FAQ'
    folder: '_faqs'
    create: true 
      - { label: 'Question', name: 'title', widget: 'string', tagname: 'h1' }
      - { label: 'Answer', name: 'body', widget: 'markdown' }
      - {
          label: "Author",
          name: "author",
          widget: "relation",
          collection: "settings",
          searchFields: [""],
          displayFields: [""],
          valueField: "",
          required: false

  - name: 'settings'
    label: 'Settings'
    delete: false # Prevent users from deleting documents in this collection
      preview: false
      - name: 'general'
        label: 'Site Settings'
        file: '_data/settings.json'
        description: 'General Site Settings'
          - { label: 'Global title', name: 'site_title', widget: 'string' }
          - label: 'Post Settings'
            name: posts
            widget: 'object'
              - {
                  label: 'Number of posts on frontpage',
                  name: front_limit,
                  widget: number,
                  min: 1,
                  max: 10,
              - { label: 'Default Author', name: author, widget: string }
              - { label: 'Default Thumbnail', name: thumb, widget: image, class: 'thumb', required: false }

      - name: 'authors'
        label: 'Authors'
        file: '_data/authors.yml'
        description: 'Author descriptions'
          - name: authors
            label: Authors
            label_singular: 'Author'
            widget: list
              - { label: 'Name', name: 'name', widget: 'string', hint: 'First and Last' }
              - { label: 'Description', name: 'description', widget: 'markdown' }

My goal is to have each FAQ entry be able to specify an author in the editor UI by selecting one via dropdown. However, I cannot get the dropdown to display a list of authors correctly. I’ve gotten the dropdown to display two blank selections (with two authors in the YAML file)…

Another resource I looked at is, which makes me believe that trying to access a nested collection should work.

Any ideas what I’m doing wrong? Or maybe this isn’t possible?

Thanks in advance.

For now you’ll need to use have your authors in individual files within a folder collection, the relation widget doesn’t currently work against file based collections:

1 Like