#Are Globals supposed to allow me to create multiple records?

8 messages · Page 1 of 1 (latest)

night moth
#

Hello, today I'm using globals for the first time. As I understand it, and as the payload AI chatbot confirmed, globals are supposed to allow me to create a single record. For some reason, inside my admin panel I can create multiple. Here is my code

import { GlobalConfig } from 'payload/types'
import { TextLeft } from '../CustomComponents/ShopBlockImage1'
import Products from './Products'
import ShopMedia from './ShopMedia'

const Shop: GlobalConfig = {
  slug: 'shop',
  access: {
    read: () => true,
    // create: () => true,
    update: () => true,
    // delete: () => true,
  },
  fields: [
    {
      name: 'title',
      type: 'text',
      label: 'Titolo'
    },
    {
      name: 'description',
      type: 'textarea',
      label: 'Descrizione'
    },
    {
      type: 'upload',
      relationTo: ShopMedia.slug,
      name: 'shopHeaderImage',
      label: 'Foto header'
    },
    {
      type: 'ui',
      name: 'shopBlock1',
      admin: {
        components: {
          Field: TextLeft,
        },
      },
    },
    {
      name: 'shopProducts',
      type: 'relationship',
      relationTo: Products.slug,
      hasMany: true,
    },
    // Add a relationship to products, so when an admin wants to list and de-list products from the shop it is easier as it doesn't need to be deleted to remove it from the Shop page
  ],
}

export default Shop

Is it normal? Thanks!

Payload "version": "1.11.5"

quaint impBOT
night moth
#

Screenshot of my admin panel

#

I have tried to drop the Shop collection from MongoDB and populated it again, but it showed the same behavior (can create multiple records)

indigo vortex
#

Where in your payload.config.ts have you added this shop global?

#

If it is in the collections array, that's the issue.. Needs to be inside a globals array in the config

night moth
#

Oh... yes it was inside the collections array