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.

How to build a custom Array field component?

default discord avatar
thgh.last year
2

I'm stuck on this error on saving the field:


Cast to embedded failed for value "1" (type number) at path "erk" because of "ObjectParameterError"
  • We are working to make this easier, but in the meantime - this will likely help you:

    https://github.com/payloadcms/payload/issues/2427#issuecomment-1512320542
  • default discord avatar
    thgh.last year

    Thanks! Noticed this too late so ended up with this:



     const toggle = useEvent(({ slug, title }: CourseMaterialTaxonomy['erk'][0]) => {
        if (selectedSlugs.includes(slug)) {
          dispatchFields({
            type: 'REMOVE_ROW',
            rowIndex: selectedSlugs.indexOf(slug),
            path,
          })
        } else {
          dispatchFields({
            type: 'ADD_ROW',
            rowIndex: selectedSlugs.length,
            subFieldState: {
              id: {
                disableFormData: false,
                valid: true,
                initialValue: undefined,
                value: slug,
              },
              slug: {
                disableFormData: false,
                valid: true,
                initialValue: undefined,
                value: slug,
                passesCondition: true,
              },
              title: {
                disableFormData: false,
                valid: true,
                initialValue: undefined,
                value: title,
                passesCondition: true,
              },
            },
            path,
          })
        }
      })
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.