Home
Support Forums

How to get non-collection object data into a collection

I would like to add “Game Links” to each “Game”. These links are arbitrary and I had hoped to just add them on the fly rather than having to create a separate collection “Game Links”.

Ideally I’m looking for a repeatable field that will accept 4 field entries.
Is this possible without creating a separate collection type?

(I know my formatting is off on the list widget. I’ve been trying a lot of different things :x Just seeing if I’m in the ballpark of possibility)

- label: "Games"
    name: "games"
    folder: "content/games"
    create: true
    identifier_field: gameNumber
    slug: 'game-{{gameNumber}}-{{opponent}}-{{gameSeason}}'
    format: 'json'
    fields:
      - {label: "Game Number", name: "gameNumber", widget: "number"}
      - {label: "Game Date", name: "gameDate", widget: "date"}
      - {label: "Game Awards", name: "gameAwards", widget: "relation", collection: "awards", search_fields: ["title"], value_field: "title", display_fields: ["title"], multiple: true, required: false}
      - {label: "Featured Image", name: "thumbnail", widget: "image", required: false}
      - {label: "Game Blog", name: "gameBlog", widget: "markdown", required: false}
      - {label: "Game Video", name: "gameVideo", widget: "string", required: false}
      - label: Game Links
        name: gameLinks
        widget: list
        required: false
        fields:
          - {label: Title, name: linkTitle, widget: string}
          - {label: URL, name: linkURL, widget: string}
          - {label: Type, name: linkType, widget: "select", options: ["Story", "Video", "Gallery"]}}
          - {label: Description, name: linkDesc, widget: string}

I was trying to do something similar to this, but it looks like “Author” in the below example is a separate collection type, while I’m just looking to add arbitrary objects that belong to the original collection type “Games”.

Or am I too worried about creating a lot of collection types and I should just create a hidden collection type “Game Links” to use here?

image

Sorry, I figured it out. I knew I was missing something simple. The below code works in giving me back the below response.

- label: "Games"
name: "games"
folder: "content/games"
create: true
identifier_field: gameNumber
slug: 'game-{{gameNumber}}-{{opponent}}-{{gameSeason}}'
format: 'json'
fields:  
- {label: "Game Links", name: "gameLinks", widget: list, collapsed: true, multiple: true, required: false,
      fields: [
        { name: linkTitle, label: Title, required: true, widget: text },
        { name: linkURL, label: URL, required: true, widget: string },
        { name: linkType, label: Type, required: true, widget: string },
        { name: linkDesc, label: Description, required: false, widget: string },
      ]
  }

image