Adds the ability to completely omit `name` from group fields now so that
they're entirely presentational.
New config:
```ts
import type { CollectionConfig } from 'payload'
export const ExampleCollection: CollectionConfig = {
slug: 'posts',
fields: [
{
label: 'Page header',
type: 'group', // required
fields: [
{
name: 'title',
type: 'text',
required: true,
},
],
},
],
}
```
will create
<img width="332" alt="image"
src="https://github.com/user-attachments/assets/10b4315e-92d6-439e-82dd-7c815a844035"
/>
but the data response will still be
```
{
"createdAt": "2025-05-05T13:42:20.326Z",
"updatedAt": "2025-05-05T13:42:20.326Z",
"title": "example post",
"id": "6818c03ce92b7f92be1540f0"
}
```
Checklist:
- [x] Added int tests
- [x] Modify mongo, drizzle and graphql packages
- [x] Add type tests
- [x] Add e2e tests
131 lines
2.6 KiB
TypeScript
131 lines
2.6 KiB
TypeScript
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfigWithDefaults({
|
|
// ...extend config here
|
|
collections: [
|
|
{
|
|
slug: 'posts',
|
|
versions: true,
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'text',
|
|
},
|
|
{
|
|
type: 'text',
|
|
name: 'title',
|
|
},
|
|
{
|
|
name: 'selectField',
|
|
type: 'select',
|
|
required: true,
|
|
interfaceName: 'MySelectOptions',
|
|
options: [
|
|
{
|
|
label: 'Option 1',
|
|
value: 'option-1',
|
|
},
|
|
{
|
|
label: 'Option 2',
|
|
value: 'option-2',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'group',
|
|
label: 'Unnamed Group',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'insideUnnamedGroup',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'group',
|
|
name: 'namedGroup',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'insideNamedGroup',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'radioField',
|
|
type: 'radio',
|
|
required: true,
|
|
interfaceName: 'MyRadioOptions',
|
|
options: [
|
|
{
|
|
label: 'Option 1',
|
|
value: 'option-1',
|
|
},
|
|
{
|
|
label: 'Option 2',
|
|
value: 'option-2',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'pages',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'title',
|
|
},
|
|
{
|
|
type: 'relationship',
|
|
relationTo: 'pages-categories',
|
|
name: 'category',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'pages-categories',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'title',
|
|
},
|
|
{
|
|
type: 'join',
|
|
name: 'relatedPages',
|
|
collection: 'pages',
|
|
on: 'category',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
editor: lexicalEditor({}),
|
|
globals: [
|
|
{
|
|
slug: 'menu',
|
|
versions: true,
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|