Skip Navigation

[Resolved] How to check if repeatable field group is populated?

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 4 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1654971

Tell us what you are trying to do?
I want to check if a repeatable field group is populated.

I tried using the if empty condition then hide but that doesn't seem to work.

#1654995

Hello,

The Toolset repeatable field groups is based on one-to-many relationship, each item of repeatable field groups is also a post, so it needs a post view, for example, create a post view:
- Query posts of your "repeatable field groups"
- Filter by relationship of your "repeatable field groups"
- In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found]
Display the information you want.

More help:
hidden link
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/

#1655023

I'm using Views to show the repeatable field group.

<h3>How to become one</h3>
[wpv-view name="rfg-career-requirements"]

For example, I want to hide the <h3> tag if the RFG view doesn't show a result.

#1655081

You can move the HTML codes:
<h3>How to become one</h3>
Into view "rfg-career-requirements", section "Loop Editor", within shortcode [wpv-items-found] ... [/wpv-items-found]

Another workaround is using CSS codes, for example:
1) Wrap your codes in a DIV tag:

<div class="hide-on-empty">
<h3>How to become one</h3>
[wpv-view name="rfg-career-requirements"]
</div>

2) Edit view "rfg-career-requirements", In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found], display CSS codes:

<style>
.hide-on-empty{display:none;}
</style>
#1656429

Thanks for the reply, Luo.

The <h3> can't be in the View. If I put it in the View, I can't use it in other blog posts. Hence I need it to be separated.

#1656485

As I mentioned above, you can try the CSS workaround:
https://toolset.com/forums/topic/how-to-check-if-repeatable-field-group-is-populated/#post-1655081

If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you.

#1661819

How about hiding a <div> on the same page if the View is empty?

For example,

On this page (hidden link), the RFG is the content under "How to become one". Screenshot: hidden link

I want to hide the

  • How to become one
  • in the Table of Contents. Screenshot: hidden link

    Stan

    #1662601

    You can try these:
    1) Modify the HTML link codes as below:

    <li class="hide-on-empty"><a href="#requirement">How to become one</a></li>
    

    2) Edit view "rfg-career-requirements", In section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found], display CSS codes:

    <style>
    .hide-on-empty{display:none;}
    </style>