feat: allow group fields to have an optional name (#12318)

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
This commit is contained in:
Paul
2025-05-14 16:45:34 -07:00
committed by GitHub
parent d63c8baea5
commit e258cd73ef
37 changed files with 955 additions and 283 deletions

View File

@@ -144,6 +144,10 @@ export interface Post {
text?: string | null;
title?: string | null;
selectField: MySelectOptions;
insideUnnamedGroup?: string | null;
namedGroup?: {
insideNamedGroup?: string | null;
};
radioField: MyRadioOptions;
updatedAt: string;
createdAt: string;
@@ -264,6 +268,12 @@ export interface PostsSelect<T extends boolean = true> {
text?: T;
title?: T;
selectField?: T;
insideUnnamedGroup?: T;
namedGroup?:
| T
| {
insideNamedGroup?: T;
};
radioField?: T;
updatedAt?: T;
createdAt?: T;