conversational-form icon indicating copy to clipboard operation
conversational-form copied to clipboard

Conditional-Flow Multiple OR'd conditions?

Open AfaanBilal opened this issue 7 years ago • 9 comments

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 avatar Jun 03 '17 07:06 AfaanBilal

@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.

felixknox avatar Jun 07 '17 06:06 felixknox

@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 avatar Jun 07 '17 12:06 AfaanBilal

@AfaanBilal Interesting case. Do you have any suggestions for how you'd like a solution to work?

danielfriis avatar Jun 08 '17 12:06 danielfriis

@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!

AfaanBilal avatar Jun 09 '17 06:06 AfaanBilal

Has someone found any solution to do OR on multiple conditions?

sajadshafizadeh avatar Jan 07 '18 09:01 sajadshafizadeh

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"

jenssogaard avatar Feb 02 '18 02:02 jenssogaard

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?

AfaanBilal avatar Feb 02 '18 03:02 AfaanBilal

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!

AfaanBilal avatar Feb 02 '18 05:02 AfaanBilal

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?

reid-markel avatar Sep 05 '19 22:09 reid-markel