Stevebenson223
Member
I have a list with several repeat groups and I'm using a custom template to display the Details view. If any of the groups are empty (i.e. no data entered), I need them to be hidden. However, the Group label is still displayed (along with the table header for one column!).
I found a possible straightforward solution in this forum post: fabrikar.com/forums/index.php?threads/hide-repeat-group-table-if-empty.45899 which made sense to me, so I copied the line:
if (count($group->subgroups) > 0) :
To make it work in my custom template, I amended it as I have specified the name of each group. So where I have a line:
$reviews = $this->groups['reviews'];
I changed the if statement to:
if (count($reviews->subgroups) >0) :
But this didn't work. The empty group still displayed the group label. However, when I changed the line to:
if (count($reviews->subgroups) >1) :
it partially worked. The empty group was hidden, while a record with two rows in the "reviews" table was displayed correctly. Unfortunately, of course, a record with only one row in the "reviews" table was also hidden.
It looks like the code is working and there are no rows for the empty group in the database table. So why does the ">0" line not work? Does Fabrik create an empty subgroup? Is there a solution or a better way to achieve this?
Thank for any guidance.
I found a possible straightforward solution in this forum post: fabrikar.com/forums/index.php?threads/hide-repeat-group-table-if-empty.45899 which made sense to me, so I copied the line:
if (count($group->subgroups) > 0) :
To make it work in my custom template, I amended it as I have specified the name of each group. So where I have a line:
$reviews = $this->groups['reviews'];
I changed the if statement to:
if (count($reviews->subgroups) >0) :
But this didn't work. The empty group still displayed the group label. However, when I changed the line to:
if (count($reviews->subgroups) >1) :
it partially worked. The empty group was hidden, while a record with two rows in the "reviews" table was displayed correctly. Unfortunately, of course, a record with only one row in the "reviews" table was also hidden.
It looks like the code is working and there are no rows for the empty group in the database table. So why does the ">0" line not work? Does Fabrik create an empty subgroup? Is there a solution or a better way to achieve this?
Thank for any guidance.