Custom form fields

default discord avatar
dzordz.
2 months ago
4

Guys I can't seem to figure it out. I created a custom form checkbox field and I can't save it do DB, it only saves blockType somehow. Weird thing is it works on local but not in production. Here is the output from API:


"id": "6507e3eac11f68a6b39b29de",
"title": "Kontakt",
"fields": [
{
"blockType": "multiple-checkbox"
},
{
"name": "text",
"label": "Text Input",
"required": true,
"id": "650809c27c5f1eb8b1fa2ba9",
"blockType": "text"
}
],


and here is my custom input code:



import { DefaultFieldProps } from "./default-field-props";
import { FieldRequired } from "./options";
import { Block } from "payload/types";

export const MultipleCheckbox: Block = {
  slug: "multiple-checkbox",
  interfaceName: "MultipleCheckboxField",
  labels: {
    singular: "Pole wyboru",
    plural: "Pola wyboru",
  },
  fields: [
    {
      type: "row",
      fields: [
        ...DefaultFieldProps,
        {
          name: "options",
          label: "Opcje",
          labels: {
            singular: "Opcja",
            plural: "Opcje",
          },
          type: "array",
          fields: [
            {
              name: "option",
              label: "Opcja",
              type: "text",
            },
          ],
        },
      ],
    },
    FieldRequired,
  ],
};
  • default discord avatar
    _veth_
    2 months ago

    Weird thing, locally it is visible under /dist/fields/forms but at production it isn't building it.



    Fixed, unrelated with Payload. It was a wrong tsconfig.json configuration which messed with build. We needed to delete dist and build folders at production, then we saw errors.

  • discord user avatar
    seanzubrickas
    Payload Team
    2 months ago

    Hey @

    veth

    glad you got this sorted out! We're around if you need anything else.

  • default discord avatar
    _veth_
    2 months ago

    All good mate, thanks! It was wrong configuration with react-email building, two folders went into dist -> src and react-email, so payload was building into src instead of straight into dist.

  • discord user avatar
    seanzubrickas
    Payload Team
    2 months ago

    that makes sense!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.