Conditional group defaultValues being saved to document object even if condition isn't true.

default discord avatar
itsjustchris
6 months ago
2

I have a few groups in a collection that appear conditionally based on checkboxes, and within those groups, I have some text fields with default values. I expected to see either no group saved to the document or, at most, an empty group object if the condition wasn't met when I added a new document to the collection.



Even though conditionally, the groups are not active when I save a document, is it expected behaviour for the group & default values to be saved on the document object?

  • discord user avatar
    denolfe
    Payload Team
    6 months ago

    Yes, this is expected behavior because conditional logic is for representation in the admin interface only. It does not affect or alter data in any way - so default values behave normally.

  • default discord avatar
    itsjustchris
    6 months ago

    I understand, thank you for clarifying.

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.