Home › Forums › General Issues › Check if subfield in row is empty, and keep last item? › Reply To: Check if subfield in row is empty, and keep last item?
This is an example or how to keep previous row values if the current row values are empty.
if (have_rows('repeater')) {
$field_1 = false;
$field_2 = false;
while (have_rows('repeater')) {
if (get_sub_field('field_1')) {
$field_1 = get_sub_field('field_1');
}
if (get_sub_field('field_1')) {
$field_1 = get_sub_field('field_1');
}
// use $field_1 and $field_2
}
}
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.