fix: fix form-builder buildInitialFormState example
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
import { FormFieldBlock } from "payload-plugin-form-builder/dist/types"
|
||||
import { FormFieldBlock } from 'payload-plugin-form-builder/dist/types'
|
||||
|
||||
export const buildInitialFormState = (fields: FormFieldBlock[]) => {
|
||||
return fields.reduce((initialSchema, field) => {
|
||||
if (field.blockType === 'checkbox') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: false,
|
||||
[field.name]: false,
|
||||
}
|
||||
}
|
||||
if (field.blockType === 'country') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: '',
|
||||
[field.name]: '',
|
||||
}
|
||||
}
|
||||
if (field.blockType === 'email') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: '',
|
||||
[field.name]: '',
|
||||
}
|
||||
}
|
||||
if (field.blockType === 'text') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: '',
|
||||
[field.name]: '',
|
||||
}
|
||||
}
|
||||
if (field.blockType === 'select') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: '',
|
||||
[field.name]: '',
|
||||
}
|
||||
}
|
||||
if (field.blockType === 'state') {
|
||||
return {
|
||||
...initialSchema,
|
||||
[field.blockName]: '',
|
||||
[field.name]: '',
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
|
||||
Reference in New Issue
Block a user