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"
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)
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
Oh... yes it was inside the collections array
Thank you!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.