Skip Navigation

[Resolved] Display content if checkbox is selected

This support ticket is created 4 years 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.

This topic contains 6 replies, has 2 voices.

Last updated by azzurraM 4 years ago.

Author
Posts
#2129561
Schermata 2021-07-30 alle 10.45.52.png

Hi,
I'm trying to set conditions to some elements on my Content Template but I wasn't able to find any past threads showing this.
I've created a Repeatable field Group, for my CPT, called "Cataloghi" with checkbox fields. I'd like it to work this way: if checkbox A is selected, show this content, if checkbox B is selected, show this other content and so on.
I'm not an expert in Conditions (especially with values, and that might be the problem), so could you help me figure out how to set this? Thank you.
Please, see screenshot

I'd prefer to share the link to my website in a hidden way, thanks

#2129791

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Repeatable Field Groups are implemented as a child custom post type of the post the fields "belong" to.

So if you have a template for that post type, to display groups of repeatable fields belonging to the post you need to use a View to query the repeatable field groups that belong to the current post.

Then in the output section of your View you can insert a Conditional block to test the values of the fields belonging to that group.

When you insert the conditional block in the context of a View querying the repeatable field group, then you should see its fields available to use in the conditions. (And note that for something like a checkbox, you will test the saved value of the field, not its label.)

Does that help, or do you need some more direction.

#2129801
Schermata 2021-07-30 alle 16.18.12.png

Thank you, Nigel!
So, I've created the view, set it to display the Repeatable field group. Inside the loop, I inserted a Conditional Block (see screenshot on the left), but when I try and set conditions, the field group does not show up..(screenshot on the right)
Am I missing something?

#2129819

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It says the source for the field is "Current Prodotto", so that sounds like the View you created is querying the Prodotto post type.

Is that what your Repeatable Field Group is called? The View needs to be querying the Repeatable Field Group.

#2129839
Schermata 2021-07-30 alle 16.38.31.png

Is that what your Repeatable Field Group is called? The View needs to be querying the Repeatable Field Group.
Screenshot:
1. The view is set to display the field group as you said
2. But it says there's nothing to display
And when I edit conditions, it pulls from Current Prodotto rather than from the Group..

#2129945

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I think the fact that the View says there are no posts to display (where by posts it really means groups of repeating fields) is the problem.

The dynamic sources try to be clever and only offer options that make sense. Because there are no posts it doesn't offer the fields belonging to the repeatable field group.

To fix the problem, make sure that the "View with" dropdown at the top of the page is using a post that actually has data to work with, i.e. it has some repeatable field groups with values for the fields.

Then you should be able to insert the condition as required. (I just tried this on my local site and got a similar result initially.)

#2129947

Oh, I see!
I followed your instructions and it's working now 🙂
Thank you very much for your help!