Support

Account

Home Forums Add-ons Repeater Field Convert Repeater to Group?

Helping

Convert Repeater to Group?

  • This is a bit of an odd one, so some background:

    We were using a plugin another developer used called “component fields”, but have decided it’s not really a fit for how we use ACF. As part of getting rid of the “components”, the plugin lets you convert their “components” into repeaters. This is fine, but all of these should really be groups – none of them “repeat”, they are just a repeaters with a single entry and will never need another entry. Having the “Add Row” button show up on these confuses the editors.

    To me, it looks like Groups are essentially just Repeaters with a single entry – you use “get_field()” on the parent for both types , and then “get_sub_field” for each child. A conversion seems possible, but I’m getting zero hits on this (I assume our situation is a bit weird – most people well… repeat in their repeaters, so conversion would make no sense).

    Any pointers on how to do a conversion of a bunch of these without losing data?

  • Yes, a group field is a repeater with a single row. However, you can’t just convert the repeater to a group. The act of switching the repeater to a group in ACF removes the sub fields.

    You can probably do this if you export the field group to json, then modify the field information in the json file to match a group field and then sync the field group. I would do this by using local JSON https://www.advancedcustomfields.com/resources/local-json/, edit the file that acf creates alter the updated time and then syn the group. The important part here will be making sure that you keep the same field/subfield names and field keys.

    I’ve never actually tried this, but it should work. But, as always, back up your site and DB before you try it.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.