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 set field to default when condition is not met?

default discord avatar
mvdve2 years ago
2

I have a select field which shows different relationship fields depending on the selection with a condition. I am running into an issue here where the hidden fields keep their data.


Is there a way to set the hidden fields to default so that only the active fields has a value?

  • default discord avatar
    hades2000822 years ago

    You could probably use beforeValidate hooks for this.

  • default discord avatar
    mvdve2 years ago

    Ah interesting, thanks!



    Used the beforeChange hook in the and. Works perfectly.

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.