Home › Forums › Add-ons › Repeater Field › repeater field not returning data › Reply To: repeater field not returning data
I have run across a similar issue, which was a repeater field returning a Boolean, and have found what was causing the problem for myself. I can’t say if its the same issue as the the original poster though.
What was happening was I was calling the same problem field for a different reason before hand ( I was doing a check to see if the repeater fields rows existed), and then trying to call the objects later in my code from the same repeater field, which was returning a Boolean of false, instead of my objects i wanted.
What seems to be happening, is that the repeater fields state, or function, or something, gets messed up when it is used before hand, and not returned to how it was before, or not being reset properly. I don’t know how this stuff is being handled exactly, but when i removed the first interaction with the field, it seems to be working fine.
<?php if( have_rows('problem_field') ): ?>
<?php $row_check = true; ?>
<?php else: ?>
<?php $row_check = false; ?>
<?php endif; ?>
<?php var_dump( get_sub_field('problem_field') ); ?>
The var_dump will return a boolean of false
Do the same thing, but essentially remove the checking of have rows.
<?php if( true ): ?>
<?php $row_check = true; ?>
<?php else: ?>
<?php $row_check = false; ?>
<?php endif; ?>
<?php var_dump( get_sub_field('problem_field') ); ?>
var_dump now returns expected object values
If i recall correctly, ive seen someone say that when they just try to call the same field twice, or cloned, or whatever, it also kinda breaks.
this doesn’t solve the issue, but hopefully is helpful for someone.
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.