This is not a bug and is working as expected. This topic comes up frequently.
Hidden field data will not be saved if the field is hidden because the field is into included with the submitted data. This also means that if the field has a previous value and then it is hidden, the field is not submitted. With no submitted field the field is not updated.
When it comes to fields with conditional logic you must check those conditions on the front end to make the decision of what conditional fields to use and you can’t rely on the presence or absence of a value in the conditional fields.
Some call this a bug and some call this a benefit. Most of my clients expect that if they change there mind 20 times that they won’t need to reenter the data 20 times. For me this is a benefit, otherwise I would end up writing something to prevent it form happening.
You can, if you choose, write an acf/save_post action to check these conditional fields and delete the content from the database for fields where you don’t want them to remember values.
For me, I’ll stick with unintuitive, verging on a bug in the case where I actually deleted the contents of a field on a page and then hid that field by unchecking a conditional checkbox. I would expect that physical act of deleting to be carried over. (As distinct from if I just checked/unchecked a conditional field, I would expect the fields & data it shows would not be affected.)
Good to know about save_post_action also, thanks.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users