Can you trigger DOM to redraw in field level hooks?

default discord avatar
KasparTr
7 months ago
1

I am facing a challenge, where the form fields should be refreshed after a relationship field is updated. The reason is that other fields are populated, using default values, based on the relationship field selection.



Is it possible to refresh the DOM in field level hooks or is there a better methods to ensure reactivity?

  • discord user avatar
    jesschow
    Payload Team
    6 months ago

    Hi @KasparTr - are you using hooks or conditional logic to populate the other fields? I'm thinking you could use an

    afterChange

    hook on the relationship field, and call your functions to populate the other fields within this hook.

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.