As a side note, I’m going to have to do something similar. I have a client that is requesting that fields that used to have a single value be changed to fields that can have multiple values with added information for each value and I’m going to need to use repeaters for this.
I cannot give specifics, because I have not worked on this yet, but I can tell you what I plan to do.
1) I will create a new repeater field with a new name
2) I will use an acf/prepare_field filter to never show the old field. The field will still exist, but will not be editable by the client. https://www.advancedcustomfields.com/resources/acf-prepare_field/
3) When a post is loaded in the admin to edit I will have an acf/load_value filter for the new repeater field https://www.advancedcustomfields.com/resources/acf-load_value/. This filter will check the old field to see if it has a value and if it does it will transfer this value to the repeater.
4) When the post is saved I will have an acf/save_post action https://www.advancedcustomfields.com/resources/acf-save_post/ that will delete any values in the old field.
5) On the front end I will use the repeater and I will also check the old field for any values and I’ll have different logic and do different things based on where the values are stored.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.