static-cms icon indicating copy to clipboard operation
static-cms copied to clipboard

Summary field of relation field

Open DynamicsNinja opened this issue 8 months ago • 5 comments

Example:

Time (Collection)

  • Id
  • Name
  • Type

Ticket (Collection)

  • Id
  • Type (Relation of Time)
  • Price

When showing summary for ticket I want to show Name field of Time instead of ID field which is defined as value_field on relation on Ticket.

collections: [
    {
      name: "ticket",
      label: "Ticket",
      folder: "content/tickets",
      create: true,
      editor: {
        preview: false,
      },
      format: "json",
      identifier_field: "id",
      summary_fields: ["type", "price"],
      slug: "{{id}}",
      fields: [
        {
          label: "Id",
          name: "id",
          widget: "uuid",
        },
        {
          label: "Type",
          name: "type",
          widget: "relation",
          collection: "time",
          value_field: "id",
          search_fields: ["name"],
          display_fields: ["name"],
          options_length: 100,
          required: false,
        },
        { label: "Price", name: "price", widget: "number" },
      ],
    },
    {
      name: "time",
      label: "Time",
      folder: "content/time",
      create: true,
      editor: {
        preview: false,
      },
      icon: "house",
      identifier_field: "name",
      summary_fields: ["name", "type"],
      i18n: true,
      format: "json",
      fields: [
        { label: "Id", name: "id", widget: "uuid", i18n: false },
        { label: "Name", name: "name", widget: "string", i18n: true },
        {
          label: "Type",
          name: "type",
          widget: "select",
          options: ["Krugovi", "Vrijeme"],
          i18n: false,
          required: false,
        },
      ],
    },
  ]

DynamicsNinja avatar Nov 10 '23 10:11 DynamicsNinja