Home › Forums › Add-ons › Repeater Field › get_field() for repeater returning string instead of array › Reply To: get_field() for repeater returning string instead of array
Incase it’s useful to anyone looking. I troubleshooted this issue down to a specific behavior in my project.
The bug
In a plugin I was authoring, I called get_field on repeater too early which caused a whole host of problems with ACF including the repeater field returning only it’s count as a string, and data seemingly not saving to the repeater when pressing the Update button.
(in reality, ACF was saving the edits properly to the database but displaying an empty repeater in the post editor as a result of this error).
The solution was to hook my ACF-dependent logic to the acf/init action instead found here:
https://www.advancedcustomfields.com/resources/acf-init/
Without hooking into acf/init, you would expect PHP to throw a fatal error and say get_field() is not a function in this case, but that didn’t happen.
I’m thinking get_field() was being called in some intermediary matter– after the get_field() function was registered, but before other functions in its call stack were available– resulting in a half-baked instantiation for that particular repeater’s data.
¯\_(ツ)_/¯.
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.