Skip Navigation

[Resolved] Form custom logic for multiple options

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

Problem:

How to use logic Operators of [cred_show_group] shortcode in post forms?

Solution:

You can use "OR" and "AND" logic Operators in your shortcodes, see our document

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/#logic-operators

This support ticket is created 3 years, 4 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 leilaG 3 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#2129279

Hi, we have previously used the below code to include or exclude a form field.

[cred_show_group if="( $(location) eq 'Location1' )" mode="fade-slide"]
[cred_show_group if="( $(location) ne 'Location2' )" mode="fade-slide"]

What code do we use if we have 5 Locations and we want to show a field on 2 of them or hide field on 2 of them?

https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/#comparison-operator

#2129537

Hello,

You can use "OR" and "AND" logic Operators in your shortcodes, see our document:
https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/#logic-operators
section "Logic Operators"

For example:

[cred_show_group if="( ( $(location) eq 'Location1' ) OR ( $(location) eq 'Location2' ) )" mode="fade-slide"]
...
[/cred_show_group]
#2131399

Thank you! That worked for the 'eq' but did not work for the 'ne'

[cred_show_group if="( ( $(location) ne 'Location1' ) OR ( $(location) ne 'Location2' ) )" mode="fade-slide"]

#2132025

The conditions you mentioned above will output the result always.

According to the description you mentioned above:
What code do we use if we have 5 Locations and we want to show a field on 2 of them or hide field on 2 of them?
You can try as I mentioned above:
https://toolset.com/forums/topic/form-custom-logic-for-multiple-options/#post-2129537

1) show a field on 2 of them

[cred_show_group if="( ( $(location) eq 'Location1' ) OR ( $(location) eq 'Location2' ) )" mode="fade-slide"]
show a field on 2 of them
[/cred_show_group]

2) hide field on 2 of them

[cred_show_group if="( $(location) ne 'Location1' ) AND ( $(location) ne 'Location2' )" mode="fade-slide"]
hide field on 2 of them
[/cred_show_group]
#2132597

Great thanks that worked!

So to hide fields we need to use AND instead of OR.