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.

Populate fields from custom field

default discord avatar
ericwaetkelast year
2

Hi, I’ve got a ui/custom field in a collection. From that component I want to populate other fields – how can I do that?



Thanks! 🙂

  • discord user avatar
    jacobsfletch
    last year

    Check out the

    useFormFields

    React hook. Details here:

    https://payloadcms.com/docs/admin/hooks#useformfields
  • default discord avatar
    ericwaetkelast year

    Ah that’s probably what I’m looking for rougly – the docs are sadly

    very

    barebones



    My current gameplan is to use

    const { dispatchFields } = useForm()

    as I need to change a bunch of Fields once a user presses a button



    dispatchFields({
      type: 'UPDATE',
      path: 'name',
      value: selectedDevice.Name,
      requiresRender: true,
    })


    When I try to do this, I get this error though

    Uncaught TypeError: dispatchFields is not a function

    Also, when I log out useForm() i get an empty object



    https://discord.com/channels/967097582721572934/1171388253333618728/1171388253333618728

    Duplicate Payload Versions in my monorepo was the culprit …

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.