Data persists in DB after changing conditional field #3204
Replies: 4 comments
-
Hey @creative-andrew, I would consider this more of a feature request than an issue. Because the Perhaps a property similar to |
Beta Was this translation helpful? Give feedback.
-
@tylandavis, you're right that we wouldn't want to run the condition on the backend as an extra step to then determine if a field should be unset or not. I think the behavior needs to be baked into the field without adding additional config properties. If a user is editing a document on the admin panel and changes a conditional field so that another field that had a previous value is removed, then on save the property needs to be assigned Would that satisfy your concerns @creative-andrew? |
Beta Was this translation helpful? Give feedback.
-
That would be great and I think it should be the expected result. Namely, we shouldn't store extra data when a condition is not met and the user saves the document. |
Beta Was this translation helpful? Give feedback.
-
@creative-andrew I'm going to convert to a discussion for now, as there are a couple things that would prevent us from being able to make these changes:
We can keep the conversation going, as there may be a better way to handle this, but it will have to consider the points above. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to reproduction
payloadcms/public-demo#25
To Reproduce
We should not store unwanted information in the collection after unchecking a conditional field.
Please check the following PR recently merged in the payload demo website that exemplifies this problem: payloadcms/public-demo#25
An easy example to illustrate the problem can be accomplished with the following steps.
Show image?
checkbox field that makes visible a field calledmedia
.field
.Show image?
field to make the media field disappear.Describe the Bug
We should not store unwanted information in the collection when the condition is not met.
It would be great to pass a configuration option wherever the condition is defined to enable this behavior.
Right now I am forced to do the following every time I define a condition in a component:
It would be great to have this out of the box, by doing something like:
So whenever the condition is not true, it should not stored (reset) to the default empty value.
Payload Version
1.9.0
Beta Was this translation helpful? Give feedback.
All reactions