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

default discord avatar
mvdve
4 weeks ago
3

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
    Kyr
    4 weeks ago

    You could probably use beforeValidate hooks for this.

  • default discord avatar
    mvdve
    4 weeks 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!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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