Skip Navigation

[Resolved] Conditional Fields in CRED form based on Selected Taxonomy

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to display conditional output based on taxonomy term withing CRED form

Solution:
You can use [cred_show_group] showrtcode in order to display conditional content withing CRED form.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/conditional-fields-in-form-based-on-selected-taxonomy-2/#post-627674

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/cred-conditional-display-engine/

This support ticket is created 6 years, 9 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by Minesh 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#627550

J S

I'd like to make certain fields show in a form based on the custom taxonomy term selected from a select dropdown. If "Video & Audio Podcasts" is selected, I'd like the associated fields to show up in the form, otherwise they will be hidden. I've tried to implement this on the following page:

hidden link

...using the following code:

[cred_show_group if="($(submission-type) eq 'Video & Audio Podcasts' )" mode='fade-slide']

<div class="form-group">
<label>Video Link</label>
[cred_field field='video-link' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>

<div class="form-group">
<label>Audio Link</label>
[cred_field field='audio-link' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>
[/cred_show_group]

The fields are being hidden as expected but I cannot get them to show up using the custom expression above. The slug for the Custom Taxonomy is 'submission-type' and the slug for the term is 'audio-visual' which I've also tried to use in the above custom expression without success.

Can you please let me know how to accomplish this properly?

Thanks

#627584

J S

Also tried this:

[wpv-conditional if="( '[wpv-post-taxonomy type='submission-type' format='slug']' eq 'audio-visual' )"]
<div class="form-group">
<label>Video Link</label>
[cred_field field='video-link' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>

<div class="form-group">
<label>Audio Link</label>
[cred_field field='audio-link' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>
[/wpv-conditional]

per this page: https://toolset.com/forums/topic/new-custom-tax-not-displayed-in-layout-front-end-but-only-in-backend/

#627585

J S

Ok I solved this using the Taxonomy ID instead of the slug.

#627586

J S

Actually, maybe you can tell me the syntax for an expression that has multiple values...I can't get this to work yet:

For example the following should show these fields if the taxonomy term does not have an ID of 18, 12, 17 or 16. It works fine for a single ID but not for multiple IDs. How do I do create an expression for multiple terms conditionals?

[php][cred_show_group if="($(submission-type) ne ('18','12','17','16') )" mode='fade-slide']
<div class="form-group">
<label>Course Title & Number</label>
[cred_field field='course-title' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>
[/cred_show_group][php]

#627674

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can use OR logical operator to build multiple conditions.

For example:

[cred_show_group if="($(submission-type) ne '18')  OR ($(submission-type) ne '12') OR ($(submission-type) ne '17') OR  ($(submission-type) ne '16')" mode='fade-slide']
<div class="form-group">
<label>Course Title & Number</label>
[cred_field field='course-title' post='submissions' value='' urlparam='' class='form-control' output='bootstrap']
</div>
[/cred_show_group]

#627735

J S

Ok, I actually ended up using an Array instead, like this:

[cred_show_group if="($(submission-type) ne  ARRAY('18','12','17','16') )"  mode='fade-slide']

It seems to do the trick. Is this ok?

I have another question regarding this form but will start a new thread.

#627744

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - it looks Ok. I gave you simple solution using OR but with ARRAY() it will work as well.