Support

Account

Home Forums Backend Issues (wp-admin) Getting error in admin: Warning: Invalid argument supplied for foreach()

Solving

Getting error in admin: Warning: Invalid argument supplied for foreach()

  • Hi There,

    Recently we’ve started to get the error in the wp-admin on multiple sites we are developing.
    [code]
    Warning: Invalid argument supplied for foreach() in C:\SITEPATH\wp-content\plugins\advanced-custom-fields-pro\pro\fields\repeater.php on line 255
    [/code]

    (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 an addition, when deleting the tabs? it starts working again as expected.

  • Any solution for this?

  • I am eagerly awaiting an update on this as well. Getting the exact error for an options page using a repeater field inside a tab component.

  • 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.

  • I was seeing this as well then i realized that i had totally forgotten to add any sub fields to the repeater in the field group. Added one and was on my way. (Version 5.3.3.2)

  • Hi guys,

    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.

  • Hi guys

    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?

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

The topic ‘Getting error in admin: Warning: Invalid argument supplied for foreach()’ is closed to new replies.