Support

Account

Home Forums Add-ons Repeater Field Warning: Invalid argument supplied for foreach()

Solving

Warning: Invalid argument supplied for foreach()

  • Hello,

    I’m new to this the ACF-Repeater. I’ve taken over a site for a customer because their previous developer is gone.

    We are getting an error when submitting a form (GravityForm) with 4 data fields that creates a table row used on the site. The error only appears upon the first time the data is submitted, creating the first table row. The data gets posted, but this error appears. Any subsequent form submissions go through fine and the error does not appear.

    Warning: Invalid argument supplied for foreach() in /home/wp-content/84/8144384/html/wp-content/plugins/acf-repeater/repeater.php on line 216

    Any insight on what would cause this to happen?

    Really appreciate anyone taking the time to respond. Let me know if more information is needed.

  • Hi @majamaki

    You might be passing the wrong data to your functions, have you tried to var_dump your variables, are they returning the expected results?

    Please checkout the following tutorial on debugging ACF data here: http://www.advancedcustomfields.com/resources/debug/

  • Not sure if this has been solved elsewhere but this is how I got rid of the Invalid argument supplied for foreach php warning

    <div id=”xx” class=”

    <?php $values = get_field(‘xxacf_field’);
    if (count($values))
    { foreach ((array) $values as $value )
    {if ($k) echo $value; }} ?>

    “>

    note: if you to have a space before and after your array values add
    echo ” “; echo $value; echo ” “;

    In this case I was using checkboxes to add style classes to wp pages.
    The only way I could get a space between the class names was to add a separate echo to either side of the values

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

You must be logged in to reply to this topic.