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.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.