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.

[Possible bug] How to clean a field using the dispatch from useFormFields?

default discord avatar
cerizesantos2 years ago
2

Hi there! I am using useFormFields to get the dispatch method for an UPDATE action. Sometimes I need to clean a field, so I dispatchName(undefined). That clears the form correctly, but when I click 'Save Draft' the old value reappears and is saved in Mongo. Any insights on what's going on?



const dispatchName = useFormFields(


([_, dispatch]) =>


(value: string) =>


dispatch({


type: 'UPDATE',


path: NamePath,


value: value


})


)



dispatchName(undefined)



P.S: it seems to work better with dispatching 'null'



@364124941832159242

Do you know if have anyone seen this before?

  • discord user avatar
    jmikrut
    2 years ago

    yeah you will need to send

    null

    to clear a field

  • default discord avatar
    cerizesantos2 years ago

    thanks

    @364124941832159242

    for confirming!

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.