Home › Forums › Add-ons › Repeater Field › Empty Group have_rows is true? › Reply To: Empty Group have_rows is true?
I think that it’s intended.
If the post has never been saved then the group has no rows but if it has been saved it will always have one row even if all the fields in the group have no value.
I think that using have_rows() is just a convenience so that you can reference the fields without the group field name prefix.
For example, lets say that you have a group field with the name of “group” and it has 2 sub fields; “field_1” and “field_2”.
You can access these fields like this:
the_field('group_field_1');
the_field('group_field_2');
or for the convenience of not added the field names together you can do:
while (have_rows('group')) {
the_row();
the_sub_field('field_1');
the_sub_field('field_2');
}
have_rows()
will always return true if the post has been saved.
Think of a regular repeater that has several sub fields but none of them are required. If you add a row to this repeater but do not enter any values into it the empty fields will be saved. This repeater will have one row even though no values have been entered into the existing row. The group field works the same way.
If you think this is a bug you are free to open a new support ticket https://support.advancedcustomfields.com/new-ticket/
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.