Files
payloadcms/test/plugin-form-builder/config.ts
Elliot DeNolf 7309d474ee feat!: type auto-generation (#6657)
Types are now auto-generated by default.

You can opt-out of this behavior by setting:
```ts
buildConfig({
  // Rest of config
  typescript: {
    autoGenerate: false
  },
})
```
2024-06-10 13:42:44 -04:00

108 lines
2.5 KiB
TypeScript

import { fileURLToPath } from 'node:url'
import path from 'path'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import type { Block } from 'payload/types'
import { formBuilderPlugin, fields as formFields } from '@payloadcms/plugin-form-builder'
import { slateEditor } from '@payloadcms/richtext-slate'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { Pages } from './collections/Pages.js'
import { Users } from './collections/Users.js'
import { seed } from './seed/index.js'
const colorField: Block = {
slug: 'color',
fields: [
{
name: 'value',
type: 'text',
},
],
labels: {
plural: 'Colors',
singular: 'Color',
},
}
export default buildConfigWithDefaults({
collections: [Pages, Users],
editor: slateEditor({}),
localization: {
defaultLocale: 'en',
fallback: true,
locales: ['en', 'es', 'de'],
},
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
await seed(payload)
},
plugins: [
formBuilderPlugin({
// handlePayment: handleFormPayments,
// beforeEmail: prepareFormEmails,
fields: {
colorField,
payment: true,
text: {
...formFields.text,
labels: {
plural: 'Custom Text Fields',
singular: 'Custom Text Field',
},
},
// payment: {
// paymentProcessor: {
// options: [
// {
// label: 'Stripe',
// value: 'stripe'
// },
// ],
// defaultValue: 'stripe',
// },
// },
},
formOverrides: {
// labels: {
// singular: 'Contact Form',
// plural: 'Contact Forms'
// },
fields: ({ defaultFields }) => {
return [
...defaultFields,
{
name: 'custom',
type: 'text',
},
]
},
},
formSubmissionOverrides: {
fields: ({ defaultFields }) => {
return [
...defaultFields,
{
name: 'custom',
type: 'text',
},
]
},
},
redirectRelationships: ['pages'],
}),
],
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})