Skip Navigation

[Résolu] Form custom logic for multiple options

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 2 années et 8 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 réponses, has 2 voix.

Last updated by leilaG Il y a 2 années et 7 mois.

Assisted by: Luo Yang.

Auteur
Publications
#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.

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