use a group field for useAsTitle #1205
-
Can I use a group field for the useAsTitle on a collection admin property?. As of now it takes String? which indicates the field name that you want to use. |
Beta Was this translation helpful? Give feedback.
Answered by
JarrodMFlesch
Oct 5, 2022
Replies: 1 comment
-
To be clear, you are wanting to use No that is not currently possible. What you could do instead is create a top level field i.e. Something like this: {
slug: 'example-collection',
admin: {
useAsTitle: 'fullName',
},
fields: [
{
admin: {
hidden: true,
},
name: 'fullName',
type: 'text',
hooks: {
beforeChange: [
({ siblingData, operation, value }) => {
if (operation === 'create' || operation === 'update') {
return `${siblingData.name.first} ${siblingData.name.last}`
}
return value
},
],
},
},
{
name: 'name',
type: 'group',
fields: [
{
name: 'first',
type: 'text',
},
{
name: 'last',
type: 'text',
},
],
},
],
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Teelon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be clear, you are wanting to use
first
as the document title?No that is not currently possible. What you could do instead is create a top level field i.e.
fullName
and use a field hook to update that based on name.first and name.last.Something like this: