Home › Forums › Front-end Issues › if statement issue subfields in group^field › Reply To: if statement issue subfields in group^field
The ACF group field is a repeater field that always has one row. The value of the field will never be empty. There are several ways you can check this.
// check each value in a loop;
$values = get_field('total', $curauth);
$empty = true;
if (is_array($values)) {
foreach ($values as $field_name => $value) {
if ($value) {
$empty = false;
break;
}
}
}
if (!$empty) {
//.....
}
// check using array_filter()
$values = get_field('total', $curauth);
$empty = true;
if (is_array($values) && count(array_filter($values)) != 0) {
$empty = false;
}
if (!$empty) {
//...
)
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.