• Resolved gestad2019

    (@gestad2019)


    Is there a way to have ‘OR’ operator inside a condition like

    show [prix9] if [compagnie] equals “Air France Tahiti” or ‘Air Antilles”
    and if [fonction] equals “H?tesse-Steward / Cabin Crew”

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    No, but this will have the same effect:

    show [prix9] if [compagnie] equals "Air France Tahiti"
        and if [fonction] equals "H?tesse-Steward / Cabin Crew"
    show [prix9] if [compagnie] equals "Air Antilles"
        and if [fonction] equals "H?tesse-Steward / Cabin Crew"

    If AND is not used, OR is implied.

    I see that in your case this leads to some redundancy. One way you could solve this to use nested groups:

    [group fonction-cabin-group]
      [group prix9][/group]
    [/group]

    This way you can Just write this:

    show [prix9] if [compagnie] equals "Air France Tahiti" 
    show [prix9] if [compagnie] equals "Air Antilles"
    show [fonction-cabin-group] if [fonction] equals "H?tesse-Steward / Cabin Crew"
    Thread Starter gestad2019

    (@gestad2019)

    ok, so it’s not possible. This was just one part of my code and in my form I need to use many conditions and as pointed I want to avoid redundancy. I dealt by repeating each options and thanks to the text editor I could may that quickly. What would be a great enhancement would be the ability to create such a logic:
    if condition 1 equals "a" or "b" and condition 2 equals "1" or "2" then field-x is shown
    Could you add this to your plugin? I’m used to the extraordinary webform on Drupal and I dream of such power in Contact form7 ??

    Plugin Author Jules Colle

    (@jules-colle)

    Can you set up a small version of your form so I can understand the logic better? You can set up the form via https://conditional-fields-cf7.bdwm.be/form-tester/

    The cases in which it’s necessary to use AND in combination with a group of OR conditions are very rare. Most of the times it can be solved by rearranging your groups a bit. I want to understand your case so I can justify spending the extra development time to create more complexity. I want to make 100% sure that it’s necessary and there are no elegant solutions possible without it. I greatly appreciate your help.

    Thread Starter gestad2019

    (@gestad2019)

    here is a copy of my form: https://conditional-fields-cf7.bdwm.be/form-tester/?hash=1359cada87fd46e42737d3945f40bdf2
    for example, you’ll see that I had to repeat all last lines instead of just writing something like:
    show [prix9] if [compagnie] equals "La Compagnie || Lux Aviation || Norse || ..." using the php syntax for OR
    I’m looking forward reading your alternative but I’m used to conditional logic and couldn’t figure out how to make it easier.
    (btw, it’s a cool tool to test a form)

    Plugin Author Jules Colle

    (@jules-colle)

    Sorry for the late reply. You might find this useful: https://conditional-fields-cf7.bdwm.be/advanced-conditional-logic-with-custom-javascript-functions/

    This option is only available in the Pro version though.

    Thread Starter gestad2019

    (@gestad2019)

    Hi Jules, thanks for your answer. I was aware i could add custom JS with the pro version. I would be a better option (even a paid one) to deal with conditions on the front end as not everybody is about to use JS (and also access to functions.php file).

    Plugin Author Jules Colle

    (@jules-colle)

    I’ll think about it. But you don’t need access to functions.php. You can add the JavaScript code straight in your form between script tags.

    Thread Starter gestad2019

    (@gestad2019)

    You’re right. Anyway, I wish you could add it a front-end setting. Would you need some funding for that?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Nested OR operator’ is closed to new replies.