* chore: ensures example configs are being exported when necessary * chore: adds note regarding updating of hidden fields --------- Co-authored-by: Jessica Boezwinkle <jessica@trbl.design>
72 lines
3.4 KiB
Plaintext
72 lines
3.4 KiB
Plaintext
---
|
|
title: Group Field
|
|
label: Group
|
|
order: 90
|
|
desc: The Group field allows other fields to be nested under a common property. Learn how to use Group fields, see examples and options.
|
|
keywords: group, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
|
|
---
|
|
|
|
<Banner >
|
|
The Group field allows fields to be nested under a common property name. It also groups fields together visually in the Admin panel.
|
|
</Banner>
|
|
|
|
### Config
|
|
|
|
| Option | Description |
|
|
| ---------------- | ----------- |
|
|
| **`name`** * | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
|
|
| **`fields`** * | Array of field types to nest within this Group. |
|
|
| **`label`** | Used as a heading in the Admin panel and to name the generated GraphQL type. |
|
|
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
|
|
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
|
|
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
|
|
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
|
|
| **`defaultValue`** | Provide an object of data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
|
|
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
|
|
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
|
|
*\* An asterisk denotes that a property is required.*
|
|
|
|
### Admin config
|
|
|
|
In addition to the default [field admin config](/docs/fields/overview#admin-config), the Group allows for the following admin property:
|
|
|
|
**`hideGutter`**
|
|
|
|
Set this property to `true` to hide this field's gutter within the admin panel. The field gutter is rendered as a vertical line and padding, but often if this field is nested within a Group, Block, or Array, you may want to hide the gutter.
|
|
|
|
### Example
|
|
|
|
`collections/ExampleCollection.ts`
|
|
```ts
|
|
import { CollectionConfig } from 'payload/types';
|
|
|
|
export const ExampleCollection: CollectionConfig = {
|
|
slug: 'example-collection',
|
|
fields: [
|
|
{
|
|
name: 'pageMeta', // required
|
|
type: 'group', // required
|
|
fields: [ // required
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
required: true,
|
|
minLength: 20,
|
|
maxLength: 100,
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'textarea',
|
|
required: true,
|
|
minLength: 40,
|
|
maxLength: 160,
|
|
}
|
|
],
|
|
}
|
|
]
|
|
};
|
|
```
|