feat: adds docs example

This commit is contained in:
Jarrod Flesch
2022-11-15 12:37:47 -05:00
parent b74ea218ca
commit 2bf0fffa0d
2 changed files with 24 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
| Option | Description |
| ---------------------- | ------------------------------- |
| **`initCollapsed`** | Set the initial collapsed state |
| **`components.RowLabel`** | React component to be rendered as the label on the array row. [More](/admin/components/#field-component) |
### Example
@@ -68,6 +69,10 @@ const ExampleCollection: CollectionConfig = {
plural: 'Slides',
},
fields: [ // required
{
name: 'title',
type: 'text',
}
{
name: 'image',
type: 'upload',
@@ -78,7 +83,14 @@ const ExampleCollection: CollectionConfig = {
name: 'caption',
type: 'text',
}
]
],
admin: {
components: {
RowLabel: ({ data, fallback }) => {
return data?.title || fallback;
},
},
},
}
]
};

View File

@@ -27,6 +27,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
| Option | Description |
| ---------------------- | ------------------------------- |
| **`initCollapsed`** | Set the initial collapsed state |
| **`components.CollapsibleLabel`** | React component to be rendered as the label on the collapsible. [More](/admin/components/#field-component) |
### Example
@@ -41,12 +42,22 @@ const ExampleCollection: CollectionConfig = {
label: 'Header of collapsible goes here',
type: 'collapsible', // required
fields: [ // required
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'someTextField',
type: 'text',
required: true,
},
],
admin: {
components: {
CollapsibleLabel: ({ data, fallback }) => data?.title || fallback,
},
},
}
]
};