Duplication of field in the editor UI

My config.yml file has a collection that use the option “file”, and it shows some fields with simple text, no images. The collections has 3 fields: “A”, “B” and “C”. When I save the info and load the CMS UI, I can see that there are 3 fields with the label “C”, and inside each of them the info corresponds to the field “A” !!!

Seems pretty much a bug or there is something I am missing?

Here is the code

collections:
  - name: "info"
    label: "Información"
    files:
      - label: "A"
        name: "info"
        file: "/_config.yml"
        fields:
          - {label: Dirección, name: "location", widget: string}
          - {label: Teléfono, name: "phone", widget: string}
          - {label: Email, name: "email", widget: string}
          - {label: Descripción, name: "description", widget: markdown}
          - {label: Misión, name: "mision", widget: text}
          - {label: Visión, name: "vision", widget: text}
      
      - label: "B"
        name: social
        file: "/_config.yml"
        fields:
          - {label: Twitter, name: twitter, widget: string}
          - {label: Facebook, name: facebook, widget: string}
          - {label: Instagram, name: instagram, widget: string}
          - {label: LinkedIn, name: linkedin , widget: string}
  
      - label: "C"
        name: "insefo"
        file: "/_config.yml"
        fields:
          - {label: Dirección, name: "location", widget: string}
          - {label: Teléfono, name: "phone", widget: string}
          - {label: Email, name: "email", widget: string}
          - {label: Descripción, name: "description", widget: markdown}
          - {label: Misión, name: "mision", widget: text}
          - {label: Visión, name: "vision", widget: text}

Attached is the screenshot of the UI where you can see the problem.

What I see is that your config refers to an identical file three times:

      - label: "A"
        name: "info"
        file: "/_config.yml"
    [...]
      - label: "B"
        name: social
        file: "/_config.yml"
    [...]
      - label: "C"
        name: "insefo"
        file: "/_config.yml"

So I guess I would expect that, unless you have different filenames than _config.yml - could you try that out?

Yes indeed I have in the _config.yml several items that I want to show them in the UI as a fields (A, B, C), so all of them are coming from the same file. So the obvious question is:
Should I create 3 .yml files so I can divide inside the collection 3 groups with these fields?

or

There is another way to just group and show in the CMS the fields I refer from the only 1 _config.yml file?

You can’t define a file collection with the same path (file: “_config.yml”) more than once.

Each file is one collection. So the best way to handle this is to create just one file collection with each field being an object (name becomes their index):

collections:
  - name: info
    label: Información
    files:
      - label: Configuration
        name: config
        file: _config.yml
        fields:
          - label: A
            name: info
            widget: object
            fields:
              - {label: Dirección, name: location, widget: string}
              - {label: Teléfono, name: phone, widget: string}
              - {label: Email, name: email, widget: string}
              - {label: Descripción, name: description, widget: markdown}
              - {label: Misión, name: mision, widget: text}
              - {label: Visión, name: vision, widget: text}
          
          - label: B
            name: social
            widget: object
            fields:
              - {label: Twitter, name: twitter, widget: string}
              - {label: Facebook, name: facebook, widget: string}
              - {label: Instagram, name: instagram, widget: string}
              - {label: LinkedIn, name: linkedin , widget: string}
      
          - label: C
            name: insefo
            widget: object
            fields:
              - {label: Dirección, name: location, widget: string}
              - {label: Teléfono, name: phone, widget: string}
              - {label: Email, name: email, widget: string}
              - {label: Descripción, name: description, widget: markdown}
              - {label: Misión, name: mision, widget: text}
              - {label: Visión, name: vision, widget: text}
2 Likes

Thank you very much @talves this is the approach I was looking for.

1 Like