Like what we’re doing? Star us on GitHub!

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

itsjustchris
2 weeks 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?

  • denolfe
    Payload Team
    last week

    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.

  • itsjustchris
    last week

    I understand, thank you for clarifying.

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More