Support

Account

Home Forums Bug Reports Repeater fields should never return a string Reply To: Repeater fields should never return a string

  • Hello @acf-support

    I’m using Advanced Custom Fields Pro 5.2.5

    I’ve always noticed this behavior though.

    For example, if you have a repeater field name ‘list’.

    $list = get_field('list');

    should return an array of sub fields. but if a post hasn’t been saved since that custom field has been added (or it has been saved but doesn’t have any rows in the repeater), it will not have any database field for that ‘list’ value, and ACF thus returns a null or 0 value. But it should return an empty array, as that is what you would get if the post had been saved with rows of values.

    You should be able to foreach (get_field('list') as $item), but right now that can result in PHP warnings because get_field('list') isn’t always an array.

    Thanks.