Skip Navigation

[Gelöst] Can you use either or logic in CRED conditional statement?

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: I would like to use "either" and "or" logic in a Forms conditional group statement.

Solution: You can add multiple rows to the conditional builder, and you can the logical operator "OR" in your conditions.

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-conditional-display-engine/

This support ticket is created vor 6 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 12 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von aaronM-9 vor 6 Jahren, 4 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#629623

I'm wondering if I can display a CRED_Group conditionally based on either one of two conditions being true. For example, I'm trying to use the following code but it doesn't seem to work.

[cred_show_group if="(($(gen-linkagerequired)+$(gen-searchstatus) eq 2)) or ($(gen-linkagerequired) eq  '0' )"  mode='fade-slide']

I've also tried using the || operator but that doesn't seem to work either, so I'm wondering if this level of logic can't be handled by Toolset or if I'm just doing something wrong with the syntax. Thanks for any help.

#629735
Screen Shot 2018-03-29 at 11.35.16 AM.png

Hi, try it with uppercase "OR" instead. When you use the Conditional Group builder you can find the options "AND" and "OR" to connect multiple conditions - I'm attaching a screenshot here.

#629776

Thanks. I feel silly for not noticing that you could add rows of different conditions. That being said, it's mostly working now except that when gen-searchstatus does not have a value it does not seem to work. Gen-linkagerequired will always be 0 or 1, but gen-search status may be 1, 0, or null (under one scenario the option group will not be visible to them so they won't be able to select yes or no).

($(gen-linkagerequired) eq  '0' ) OR ($(gen-linkagerequired)+$(gen-searchstatus) eq  '2' )

Is there some additional code I can include to make it still function when gen-searchstatus is null?

#629780

If gen-searchstatus is null, does the value of gen-linkagerequired matter?

#629785

I wouldn't think so, but right now the conditional statement only seems to be working when both gen-linkagerequired=1 and gen-searchstatus=1. When gen-linkagerequired=0 the CRED_Group does not become visible. Can you think of another reason it wouldn't be be showing up? I'll include the full code below:

	<div class="form-group">
      <label>Type of Item</label>
      [cred_generic_field field='gen-linkagerequired' type='radio' class='' urlparam='']
      {
      "required":0,
      "validate_format":0,
      "default":[],
      "options":[
      {"value":"1","label":"This is an item that can be bought elsewhere."},
      {"value":"0","label":"This is a custom item or a service not currently offered or easily found."}
      ]
      }
      [/cred_generic_field]
	</div>

    [cred_show_group if="($(gen-linkagerequired) eq  '1' )"  mode='fade-slide']

        <div class="form-group">
          <label>Link to Item on Be.Education</label>
          [cred_generic_field field='gen-searchstatus' type='radio' class='' urlparam='']
          {
          "required":0,
          "validate_format":0,
          "default":[],
          "options":[
          {"value":"0","label":"I have not yet searched for this item on Be.Education"},
          {"value":"1","label":"I have searched for this item and cannot find it."}
          ]
          }
          [/cred_generic_field]
        </div>

        [cred_show_group if="($(gen-searchstatus) eq  '0' )"  mode='fade-slide']
            <p>Your buy/swap/sell listing will be more successful if you link to an existing product or service on Be.Education.  Here's how you do it:</p>
            <ol>
              <li><a href="/?private-page=products">Search for the product or service.</a></li>
              <li>On the product detail page, click the button under the product image to create your buy/swap/sell listing.</li>
            </ol>
        [/cred_show_group]

        [cred_show_group if="($(gen-searchstatus) eq  '1' )"  mode='fade-slide']
            <p>If the item does not currently exist on Be.Education, create your buy/swap/sell listing by filling out the following form and we will take care of the rest!</p>
        [/cred_show_group]

    [/cred_show_group]

    [cred_show_group if="($(gen-linkagerequired) eq  '0' )"  mode='fade-slide']
        <p>Please add your buy/swap/sell listing by completing the following form:</p>
    [/cred_show_group]

[cred_show_group if="($(gen-linkagerequired) eq  '0' ) OR ($(gen-linkagerequired)+$(gen-searchstatus) eq  '2' )"  mode='fade-slide']
	<div class="form-group">
		<label>Headline</label>
		[cred_field field='post_title' post='ad' value='' urlparam='' class='form-control' output='bootstrap']
	</div>

...

Right now the form does not display if the gen-linkagerequired value gets set to 0.

#629849

Okay this is a tricky one, and I'm not able to get it to work unless I have selected something in the hidden field at least once. Let me reach out to my 2nd tier support team for some clarification. It may be a limitation of the CRED conditional engine, or it could be a bug. I will let you know what I find out.

#630347

Just a quick update to let you know my 2nd tier team has asked the CRED developer team for some additional information. I will update you when I have additional information to share.

#660493

Hi - I'm just checking in on this to see if there's been any movement. Thanks for any updates.

- Aaron

#667575

Hi, our developers do not have a permanent solution for this yet but for now they recommend setting a default value of 0 in the second field to select the "I have not yet searched..." radio.

#917994

Hi, an update to let you know we plan to include a fix for this in Forms 2.0.1, which is expected to be released very soon. I'll keep you posted here.

#918035

That's great - thanks for the update.

#922255

Hi, please find Forms 2.0.1 available for download or automatic update and let me know if the issue is not resolved.

#922604

All set! Thanks.

- Aaron