Skip Navigation

[Resolved] Conditional logic in forms

This support ticket is created 3 years, 6 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by mikes-33 3 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#2043279

This is a taxonomy drop-down on a form:

<div class="form-group">
<h5>Choose the type of artwork you're sending us</h5>
<label for="%%FORM_ID%%_work">[cred_i18n name='work-label']Artwork Type[/cred_i18n]</label>
[cred_field field='work' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
</div>

I want to show a conditional group if the selected taxonomy is Audio:

[cred_show_group if="( $(work) eq 'Audio' )" mode="fade-slide"]
[cred_i18n type="html" name="scaffold_field_id"][/cred_i18n]
<div class="form-group">
<label for="%%FORM_ID%%_audio">[cred_i18n name='audio-label']Audio File[/cred_i18n]</label>
[cred_generic_field type='audio' field='audio']
{
"required":0
}
[/cred_generic_field]
</div>[/cred_show_group]

But the field doesn't show, ever... unless I set to "ne 'audio'" then it shows even when taxonomy IS audio.

#2043523

Hi,

Welcome to Toolset support and I'd be happy to assist.

In the select field for taxonomy, each term's ID (and not term title) is used as the value.

For this reason, you'll also need to use the term's ID in the conditional check.

Example:


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

Note: Please replace 123 with the actual ID of the Audio term in the work taxonomy.
( here is a guide on how can you see the term ID: hidden link )

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2046483

My issue is resolved now. Thank you!