Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Custom form fields

default discord avatar
dzordz.2 years 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 years 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
    2 years ago

    Hey

    @432257066292346882

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

  • default discord avatar
    _veth_2 years 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
    2 years ago

    that makes sense!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.