### What? Allows to overwrite the default placeholder text of select and relationship fields. ### Why? The default placeholder text is generic. In some scenarios a custom placeholder can guide the user better. ### How? Adds a new property `admin.placeholder` to relationship and select field which allows to define an alternative text or translation function for the placeholder. The placeholder is used in the form fields as well as in the filter options.   --------- Co-authored-by: Dan Ribbens <DanRibbens@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
42 lines
863 B
TypeScript
42 lines
863 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { placeholderCollectionSlug } from '../slugs.js'
|
|
|
|
export const Placeholder: CollectionConfig = {
|
|
slug: placeholderCollectionSlug,
|
|
fields: [
|
|
{
|
|
name: 'defaultSelect',
|
|
type: 'select',
|
|
options: [
|
|
{
|
|
label: 'Option 1',
|
|
value: 'option1',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'placeholderSelect',
|
|
type: 'select',
|
|
options: [{ label: 'Option 1', value: 'option1' }],
|
|
admin: {
|
|
placeholder: 'Custom placeholder',
|
|
},
|
|
},
|
|
{
|
|
name: 'defaultRelationship',
|
|
type: 'relationship',
|
|
relationTo: 'posts',
|
|
},
|
|
{
|
|
name: 'placeholderRelationship',
|
|
type: 'relationship',
|
|
relationTo: 'posts',
|
|
admin: {
|
|
placeholder: 'Custom placeholder',
|
|
},
|
|
},
|
|
],
|
|
versions: true,
|
|
}
|