Skip Navigation

[Resolved] Taxonomy-based Conditional Groups in Post Forms

This support ticket is created 3 years, 8 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 4 replies, has 2 voices.

Last updated by jenniferK-7 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1727699

Tell us what you are trying to do?

I have form for creating a new post, and I would like certain sections to appear only when a given taxonomy is selected in the form.
ex) I select the term "Restaurant" and a field appears, "Restaurant Specialty"

Is there any documentation that you are following?

I started here: https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/
This page states that taxonomies can be used, but does not go into enough detail.

On further research I found plenty of documentation for wpv-conditional statements, and even found that they can do exactly what I want in the GUI, but eventually found that they seem to operate slightly differently than cred-show-group conditionals, and I cannot use shortcodes in the same way. https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one

Before creating this ticket I performed a search and came across this case, which is very similar to mine, however my terms seem to have text slugs, not IDs, despite the taxonomy being hierarchical (perhaps I am misunderstanding how to check; I cannot find terms in wp-admin) https://toolset.com/forums/topic/dropdown-does-not-affect-visibility-of-fields/

#1727919

Hello,

You can try to check with term name, for example:

	[cred_show_group if="( $(category) eq 'Uncategorized' )" mode="fade-slide"]Display something[/cred_show_group]

Please replace "category" with the custom taxonomy slug, replace "Uncategorized" with your specific term's name, and test again

#1729977

Hi Luo,

Thank you for the response. I have tried with both term name and slug, and it still does not work. This was originally taken from a larger form made with the GUI editor, but I isolated it down to just this much to test:

[credform]
	[cred_field field='form_messages' class='alert alert-warning']
	<div class="form-group">
		<label>Listing Types</label>
		[cred_field field='listing-type' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
	[cred_field field="listing-type_add_new" taxonomy="listing-type" type="add_new"]
	</div>
	[cred_show_group if="( $(listing-type) eq 'Tourism' )" mode="fade-slide"]
	<div class="form-group">
		<label>Restaurant Specialty</label>
		[cred_field field='restaurant-specialty' force_type='field' class='form-control' output='bootstrap']
	</div>[/cred_show_group]
	[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]

Edit: I would love if there was a debug option for this, like in the wpv-conditional statements

#1730199
tag_ID.JPG

Thanks for the details, since you are using single select dropdown for the taxonomy field, you can try to compare the value with term's ID, for example:

 [cred_show_group if="( $(listing-type) eq '123' )" mode="fade-slide"]
...
[/cred_show_group]

Please replace 123 with the taxonomy term "Tourism" ID, you can get the term's ID by edit it in WordPress admin side, see screenshot: tag_id.JPG

#1731965

That worked, thank you very much !

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.