38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import type { Plugin } from 'payload'
|
|
|
|
import { formBuilderPlugin } from '@payloadcms/plugin-form-builder'
|
|
|
|
import type { FormsOption } from './types.js'
|
|
|
|
/**
|
|
* Configures @payloadcms/plugin-form-builder from IPAL's FormsOption.
|
|
*
|
|
* Provides the form/form-submissions collections and field types. Email
|
|
* delivery is intentionally NOT handled here — the plugin's own SMTP-from-panel
|
|
* sender (submitForm) does that, so the form-builder's built-in email (which
|
|
* needs a Payload email adapter) is left unused.
|
|
*/
|
|
export function buildFormsPlugin(forms: FormsOption): Plugin {
|
|
return formBuilderPlugin({
|
|
fields: {
|
|
checkbox: true,
|
|
email: true,
|
|
message: true,
|
|
number: true,
|
|
payment: false,
|
|
select: true,
|
|
text: true,
|
|
textarea: true,
|
|
...forms.fields,
|
|
},
|
|
...(forms.redirectRelationships ? { redirectRelationships: forms.redirectRelationships } : {}),
|
|
// Client-supplied collection overrides (e.g. a per-form notification
|
|
// address). The plugin provides the hook, not the opinion about which
|
|
// extra fields a form should carry.
|
|
...(forms.formOverrides ? { formOverrides: forms.formOverrides } : {}),
|
|
...(forms.formSubmissionOverrides
|
|
? { formSubmissionOverrides: forms.formSubmissionOverrides }
|
|
: {}),
|
|
})
|
|
}
|