Recently we’ve started to get the error in the wp-admin on multiple sites we are developing.
Warning: Invalid argument supplied for foreach() in C:\SITEPATH\wp-content\plugins\advanced-custom-fields-pro\pro\fields\repeater.php on line 255
(I put SITEPATH in myself for this post).
Essentially any ‘repeater field’ seems to get this error. Not immediately, it can be random, i can put in data, save it, it shows, and later on, suddenly this error shows up, yet the data on the frontend displays.
I’m unsure if it’s relevant, but the repeaters are in tabs, and some of the repeater fields have the same names as the tab above it, yet this has never cause issues in the past.
Any solution would be great as it’s a major problem, we used ACF pro on a daily basis for our development work.
Just to be helpful, I believe the problem occurs when the slug for the repeater field and the slug for the tab are the same. The tab slug isn’t visible but it is created behind the scenes from the title you gave it when it is first created. Changing your repeater slug or deleting and recreating your tab with a different name does the trick.
First off, this is not a breaking issue as you noticed. It’s a php warning so while it’s annoying you can safely use ACF as usual.
You’ve stumbled upon a bug where ACF interprets the tab field as a repeater as well (due to the same naming as an actual repeater). The code then tries to iterate through a repeater value which isn’t there resulting in this warning.
I’ll notify Elliot of this issue so he can patch it for the next update. It’s an easy fix 🙂
In the meantime if this still bugs you you can do what @refused9 suggests and create a new tab field with a slightly different name. After you save the field group I think you can change the name back to be the same as the repeater and it should be fine.. since the slug already exists.
I’ve just spent some time testing this issue but can’t replicate it.
I may have fixed it by accident in some recent improvements to the tab field (ensuring it saves an empty name) which will be part of the next version (5.4.0).
If you have this issue on a site online, can you please get in touch and share login details for me to debug?
The topic ‘Getting error in admin: Warning: Invalid argument supplied for foreach()’ is closed to new replies.
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!