I am working with a
page.changeStatus:after hook. In this hook, I change my template from
publishedproject if I set the status to listed (for permission fine tuning reasons) and vice versa from
publishedproject back to
project when I change it back to unlisted or draft.
I have a field
palette that only exists in the template
publishedproject. Now, when I change the status from draft to published, the new
palette field will be created with no value, as expected.
Here’s the problem: When I now set a value to that field, and change the status back to draft (and therefore the template changes back to
project), it keeps the field with the set value (which is good). If I now change the status back to listed (and therefore back to the
publishedproject template, it seems to newly create the palette field and deletes what was saved in that field. It seems like Kirby is not checking if the field already exists in the content file, but just creates it on the template change and therefore deletes the previously saved value.
Is this the intended behaviour? Or should I report it as a bug? Either way, how can I work around this and keep the value, even if I switch the template?