customize admin-appearance of array-element-headers (similar to defaultColumns/useAsTitle) #808
Replies: 4 comments 5 replies
-
I started playing around with this feature at https://github.com/vincentvandijck/payload/tree/feat/arrayfield-admin-columns-useAsTitle I made a naive implementation of
The title currently only updates when the collection is saved. If there is a way how it could reactively update lmk. I know it must be possible, as this is the behavior with useAsTitle when you haven't saved yet (after you saved it does not update reactively anymore, neither after a save, I don't know if this is expected behavior or a bug), but I haven't properly looked into it yet. I am displaying everything as a string for now. |
Beta Was this translation helpful? Give feedback.
-
OK so here's my thoughts on how this pattern should work. It should function very similarly to how our
From there, you could take whatever data you needed from the form and compose an intelligent label. Payload would basically be responsible internally for retrieving the data and siblingData, and then passing to the custom Description component. To retrieve the data from the form, you'd do: const { getData, getSiblingData } = useForm();
const data = getData();
// the path, including the index, of the current array field is needed here.
// It would be something like `array.0` where `array` is the current array field's path, and `.0` is the index of the row
const siblingData = getSiblingData(path); Collapsible UsageWith the Collapsible component, we could not simply extend the existing In order for this to not be a breaking change, we would need to "sanitize" collapsible fields. If the user passes a string as a label, but no name, then we can set the name of the collapsible field during sanitization, equal to the label. This will ensure that collapsibles properly always have a But, if the user passes a React component as a Array / Blocks UsageHere, we could add another property to the array / block fields Does this make sense? |
Beta Was this translation helpful? Give feedback.
-
This is now complete. |
Beta Was this translation helpful? Give feedback.
-
Closed with this PR Docs here |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At the moment arrays are being displayed collapsed as the following:

I propose a feature similar to
defaultColumns
in the admin-property of the CollectionConfig, with which we can define how the list of entries of a collection is being displayed:becomes
This would allow for a much better overview in collapsed view, especially important when dealing with big arrays.
When you do not provide a
defaultColumns
(I guess we could call itcolumns
as the cms-user won't be able to adapt it themselves), it could just default to the auto-indented view we have now.Beta Was this translation helpful? Give feedback.
All reactions