conversational-form
conversational-form copied to clipboard
Conditional-Flow Multiple OR'd conditions?
Hi,
Can we have multiple conditions but the logic OR instead of AND?
<input
type="text"
cf-questions="Question to ask.."
cf-conditional-cfc-hello="world" /> <!-- will check for name attribute cfc-hello -->
cf-conditional-cfc-world="hello" /> <!-- will check for name attribute cfc-world -->
The above example question will only be shown when BOTH the conditions:
- cfc-hello="world" and
- cfc-world="hello" are met.
Is there a way to make it so that even if only one of the multiple conditions is met, the question is still shown?
Thanks!
@AfaanBilal would this work: cf-conditional-cfc-hello="||world"
here the conditional would go through if "no value" and value "world". I can add it tomorrow.
@felixnielsen Thanks for responding!
Wouldn't this go through if both cfc-hello
and cfc-world
are left blank?
I need at least one of them to have the required value.
@AfaanBilal Interesting case. Do you have any suggestions for how you'd like a solution to work?
@danielfriis Maybe something like this could be done:
<input
type="text"
cf-questions="Question to ask.."
cf-or-conditional-cfc-hello="world" /> <!-- will check for name attribute cfc-hello -->
cf-or-conditional-cfc-world="hello" /> <!-- will check for name attribute cfc-world -->
The cf-or-conditional
could be evaluated in the same way as the existing cf-conditional
except that multiple cf-or-conditional
should be joined with an OR ||
instead of an AND &&
.
Would that be possible?
Thanks!
Has someone found any solution to do OR on multiple conditions?
Hi @AfaanBilal I have been testing your PR and playing around with it. However, I do see an issue when we start combining cf-conditional (&&) with the cf-or-conditional (||). As I see it any cf-conditionals on the same tag as cf-or-conditional will be ignored, correct? Do you have any ideas as to how we could solve that?
cf-conditional-cfc-beer="ipa"
cf-or-conditional-cfc-intro="yes"
cf-or-conditional-cfc-please="yes"
Hi @jenssogaard Yes, you're right.
So, the behavior that we desire should be that all cf-conditional
tags must evaluate to TRUE
and at least one of the cf-or-conditional
tags must evaluate to TRUE
for the form tag to be shown, right?
Hi @jenssogaard I've pushed a new commit to the pull request that solves this issue implementing the logic as in my comment above.
Thanks!
I'm still having a conditional problem, I read the docs and followed the instructions for multiple conditionals and no dice. Is this a bug that's going to be fixed in the near future?