How to set field to default when condition is not met?

default discord avatar
7 months ago

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
    7 months ago

    You could probably use beforeValidate hooks for this.

  • default discord avatar
    7 months ago

    Ah interesting, thanks!

    Used the beforeChange hook in the and. Works perfectly.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.