Hi everyone,
This is not a question, just want to help anyone who is struggling with the same issue I just spent 6+ hours debugging to solve. Perhaps someone from the team of excellent people who develop this plugin might find it useful to be included in the official documentation. 🙂
tl;dr If you are not calling acf_form_head()
in the template file (as is in the documentation example), but somewhere in your theme’s function.php
or in the plugin files, make sure you wrap it in an init
hook callback, otherwise some unexpected things might happen.
The context: I have created an admin page (probably not that relevant) for a plugin, and was calling acf_form_head()
somewhere in the main plugin php file, with a check for $_GET['page']
to match the slug of my page. On the template for my custom page I have called acf_form()
with args, and everything seemed fine. I was able to submit some basic fields, text, image, even taxonomy terms… but repeaters? Nope. When I submit any data, all repeaters are deleted. Only repeaters.
I tried to save the same field group through the native form, everything worked. I started debugging and found out that when submitting through the acf_form()
generated form, filter acf/update_value/type=repeater
is not triggered in acf-value-functions.php:188
, while it is triggered when I submit it through the normal acf form. Everything else worked fine…
Long story short, inspecting the context and available classes, I found out that the class acf_field_repeater
was not available at all. Then I found out that acf_form_head()
doesn’t only enqueue the scripts/css, but also does the form processing, and it matters very much when it is called. So I put it into the init
hook callback, and everything worked properly.