Skip Navigation

[Resolved] On my website the Toolset Conditional for Custom Fields does not behave the same way as on a fresh install

This support ticket is created 6 years, 5 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Author
Posts
#909505

This is how toolset Conditionals behave usually:
hidden link

This is how they behave on my website:
hidden link
hidden link

Access to the site is shared here:
https://toolset.com/forums/topic/conditional-remaining-selection-bug/#post-906576

Beda knows how to proceed.

#909595

Sorry, but is it on this topic about BUG report or about (never asked) feature request?

#909803

This is about the problem, that on your website, the Conditionals seem to not work as expected.

This ticket here is about the Post Field Group hidden link

I see that you have several Select Fields there and each is shown conditionally according some values of other fields in the same group.

I tested this conditions one by one on your website, and here are the results:

- Create a new post in "Test Posts II"
- Select "Country II*" values:
-- United States
--- "US States II*" is shown
==> Correct result since the condition to this field is "Country II = 1"
- Select "Country II*" values:
-- Ecuador
--- "Ecuador Provinces II*" is shown
==> Correct result since the condition to this field is "Country II = 2"
(I skip the rest of first level checks in this report as we can safely assume first level works fine)

- Select "Country II*" values:
-- United States
--- "US States II*" is shown
---- Select "Texas", "Texas Cities II*" is shown
==> Correct result since the condition to this field is "US States II = 1".
(I skip the rest of first level checks in this report as we can safely assume first level works fine)

Now do a stress test, and break the FIRST condition which will hide the second, and since the second is now hidden, you expect the third to be hidden as well.
But that does not happen, and here the whole confusion comes from

See, this is what happens:
Parent
- Child, shows only if parent is OK
-- GrandChild, shows only if CHILD is OK, but is completely independent from PARENT!

So to solve this, you would need to adapt the condition of the GrandChild, you will need to tell it, that it can show only if the Child is not shown (it's own parent) AND the Parent (grandparent condition to this Grandchild)

I added an example Custom Field group in the Website you shared with me:
hidden link

It applies the Conditional Logic I explain above

If you now create a new post in Test Posts II and test the field group "Toolset test Fields group" you will see that if you break the most parent item, all it's Childs are hidden.

This does NOT remove the problem that the data is STILL saved in the database!
This resolves the problem that the fields where still shown in the Edit area

The other issue with the data still saved, is discussed here:
https://toolset.com/forums/topic/conditional-remaining-selection-bug/

I think with this information you should be able to use the conditional in the way you require

#910735

1) "But that does not happen, and here the whole confusion comes from"

Finally, that was the GOAL of topic/problem (my initial, other).

2) "So to solve this... "

So, the whole problem lies in the fact that in Toolset tutorials is no 'sign' (note/remarks) that the conditional logic implies that each field in the chain must be entered in the construction of a conditional logic conditions (and with criteria = ALL, not OR), because the interruption (break) of the "hoop" (grummet/link) in the any part of the chain will lead to a problem in the display (edit) of data, for reasons that Toolset despite of the breakage of the "chain" (so, despite that data don't met conditions anymore), retain the data, non explicitly (directly) removed, in the database.

Thanks to find the issue and solve the problem.

#910869

Unfortunately, system not working, or I'm doing something wrong (I don't think).

I didn't noticed that fact how Toolset keep data in database, will work ONLY with "AND" operator, what any custom conditional logic exclude as option (as it is about mix of AND with OR). Fact that Toolset keep "orphan" (rather - "garbage") data in database, makes operator OR completely useless for conditional logic, by definition (see further), as that OR mean that those "orphan" data still can be displayed.

Now, for such reasons, I'm with REAL LIFE DATA in problem.

Please, go to same website and see "Tipo de sitio" Field Group (and watch demo post of "Sitios" - already set on right level of steps). Problem start where I have two levels of fields (Espacio geográfico > Espacio natural (with selection of Parque) > Parque > Protección por ley > Grado de protección):

1) Espacio natural where appear "problematic" selection of Parque in next level(s).

2) Parque Problem is "Parque urbano", where is no (further fields of) Legislation Protection, what create that problematic 'two level' conditional logic.

That produce two problems:

1) If I set all selections with AND (with or without Parque), it will not works as it mean that ALL CONDITIONS MUST BE SATISFIED (in selection you cannot check all fields, only one) So, only custom conditional logic will makes that Toolset will keep selection of Parque (or not??? - at first, looks that will not keep) if it will looks as (for "Protección por ley"), and conditional logic extended on two level of fields (so, it should to appear in all except one case - but don't forget how could be in other situation any relation of percentage):

($(espacio-geografico) eq 3) AND ($(espacio-natural) eq 2) OR ($(espacio-natural) eq 3) OR ($(espacio-natural) eq 4) OR ($(parque) eq 1) OR ($(parque) eq 2) OR ($(parque) eq 3)

2) However, that makes me problem further in the chain:

a) First, 'normal' custom logic in "Grado de protección" not working:

($(espacio-geografico) eq 3) AND ($(espacio-natural) eq 2) OR ($(espacio-natural) eq 3) OR ($(espacio-natural) eq 4) OR ($(parque) eq 1) OR ($(parque) eq 2) OR ($(parque) eq 3) AND ($(proteccion-por-ley) eq 1) AND ($(grado-de-proteccion) gte 1)

Not working either with

($(espacio-geografico) eq 3) AND ($(espacio-natural) eq 2) OR ($(espacio-natural) eq 3) OR ($(espacio-natural) eq 4) OR ($(parque) eq 1) OR ($(parque) eq 2) OR ($(parque) eq 3) AND ($(proteccion-por-ley) eq 1) OR ($(grado-de-proteccion) gte 1)

b) Second, already next (several fields), not working (expected), with those extended (for me) "new conditional system".

Well, what now?

P.S. You are free to try whatever combination of conditional logic, to try to apply and show me where I make mistake (as I don't think that I make mistake).

REMARKS

I wrote that life is 'live' think and nobody can predict possible combinations. here appear that I should to exclude "Parque urbano" to make it to work, or I missed something. Also, please pay attention that I will have significantly more complicated combinations (as that is about the real life situations and not some 'small test').

And this is what I talk, not even significantly extended web development job on conditional logic will help (or I'm wrong, we'll see).

#910911

OK, my bad (my mistake).

Conclusion that it can work only with AND operator is correct, but I forgot to try other conditional options. So it (looks that all) works fine with code:

($(espacio-geografico) eq 3) AND ($(espacio-natural) gte 1) AND ($(parque) lte 3) AND ($(proteccion-por-ley) eq 1) AND ($(grado-de-proteccion) gte 1) 

I have here additional question. As I cannot duplicate fields (in theory, there is workaround), and I must manually to enter line per line conditions, is it some difference from manual entrance and just to paste above code as Custom Logic?

Also, please wait until Monday to close ticket as until than I think that I will finish first CPT Sitios and see (test) how it works.

#911038

You can set up the condition and then click "Advanced text mode".
You will see your condition converted to the syntax, which you can then use to adapt new conditions, yes.
So you can directly click on "Advanced text mode" and insert the condition and after editing it to match the current field, save it.

As for AND/OR, in a conditional statement by logic you need to repeat the entire logic if you want to match an OR with several AND…

Lets say, you want:
IF a, b, c AND (d, OR e, OR f)

Then you need to rewrite the entire AND part for each OR part, logically, there is no way around that
Then the condition looks like:
IF (a, b, c AND d) OR (a, b, c AND e) OR (a, b, c AND f)
(Of course you cannot copy paste above - it is just for the logical explanation how conditions work)

Each condition applies EXACTLY and ONLY to what it says.

Or, as you do, you can check on greater/smaller or other comparators, which can make sense if you want to show a field let's say if option 3,4,5 are checked, you can say "IF (a > 2)"

Anyway, I see in your second post you seem to have had success with this by now.

Remember that the conditions are only about what is DISPLAYED, and not about what is SAVED.
That part, for now, is under the responsibility of the EDITOR or creator of this posts/content.

#911933
002.png
001.png

On website is something broken and Minesh is on it (other ticket), so please be patient.

It looks that I will finish it successfully, but with 2 issues (until now):

1) It is impossible (I could not to do it) to mix conditions within levels of repeater groups (so, nested groups). Simply, fields from one level not react on field from other level. When I pull it out from nested group, it works (with same conditional logic).

2) I can't handle how to order it within parent post. Sites are child of Destination (where are Province, Canton and Parish). I have all provinces and canton's within Site post. At first look, that is different issue, but I have that issue within Climate. Example of Destination Canoa where is present (selected) 2 of 46 possible climates. When I open Site within Canoa destination, I should to have option to choose one climate (coastal part or inland) just within those 2 climates and not all 46. That should to be within scope of conditional logic (or not?).

#912154

Now I can confirm that conditional logic not working in Repeater Groups deeper than first level. It is not clear for me as they are only hidden post types and if I 'chain' post types, it will work.

As there is the problem with Module Manager (other ticket) I created other website (please open private link if you want to see) with clean state of only original theme (17) and Toolset (nothing else is there). I created new CPT - Negocios with 5 business types (first select field) and than I started to 'nest' repeater groups and ordinary fields within conditional logic. If fields are within CPT itself, conditional logic works, when I place same fields within (nested) repeater group, fields not appear at all. Example is Business Type (Accommodation) > RG - Rooms (ie Room Type = Individual) > Nested RG - Beds (ie Bed Type = Single).

So, if I pull out Bed Types, conditional field working, if it is in nested RG, it is not even visible in Dashboard.

I didn't tried, but I'm 101% sure how it will works if I will make ("chained"/nested) Child Posts, but in nested RG its not working.

My problem is that I don't thought to work with those chained child posts, as entire concept of project is different and I can finish with huge mess if I will have too many CPT's.

I have Main post type Destinations and child post types Sites (Attractions), Places (non profit subjects - info) and Business (Negocios). From Negosios I have Accommodation, Gastronomy, Services, Products and Services & Products. Than From Accommodation I have (ie) Rooms, Opening Hours, ...

If it is possible that vs problem with administrative chain (see my reply before) I need also more post types, how deep I will need to go if I will just work with visible post types, instead of hidden (Repeater Groups)???

And all because of conditional logic.

#912270

There is a BUG with Conditionals in Repeating Fields Groups, eventually this is what you see now.

That is, when you show a Field within a Repeating Field Group conditionally to a Field outside that group, the field will not save that value.
This BUG was reported and is handled here:
https://toolset.com/forums/topic/after-repeatable-group-field-set-show-conditionit-is-not-to-save

I don't know what private reply you refer to as I have no private reply active on this thread here, and on the only private reply I have (https://toolset.com/forums/topic/conditional-remaining-selection-bug/#post-906576) the Theme used is a Genesis Child Theme so I assume that is not the site you refer to.

I activated a reply so you could submit the new details to the new site in case the BUG above shared is not what you see.

Thank you!

#912344

1) BUG about not saving I noticed, but this is different. Actually, I'm not sure is it save or not, but certainly, value is not shown as saved after pressing the save.

2) Also in this link (what you have, where is now broken Module Manager), you can see how conditional logic not works in second level of repeating groups. However, explained example (with rooms) is on other link and I can't post you link as no private link is opened (I think that you forgot to open it).

#912410

I opened a private link

Please lets remain on the last one issue here:
The condition within the repeating field groups.

Please let me know the accesses and links.

Thanks!

#912683

Now, it looks even worst. My idea was that I have within Negocio 5 types and let the selectable field in Repetable Group to get option to have multiple businesses under same user account. Example (very common) is hotel with restaurant.

Now, as it should to be initial value, any further fields within post are not anymore visible (as all depends on conditional logic on this initial selectable field).

So, what now?

P.S. Regards the fact that I create Field Groups, I will pull out selectable field out of Repeatable Group.

#912928

1. I tested the conditions of this Field Group:
hidden link

- The Field "Número total de habitaciones" is shown only if the Field of another Group "Tipo de negocio" es 1 (Alojamiento).
This works.
- If I add a Group of "Group de tips de habitacion" (which is NEVER hidden, only its inner FIELDS can be conditional), then:
-- Tipo de habitación (same condition as above)
-- Clase de habitación (same as above)
-- Número de habitaciones (de este tipo) (same as above)
-- Selecciona la política de fumadores (same as above)
-- Tamaño de la habitación (opcional) (same as above)
-- Unidad de medida del tamaño de la habitación (same as above)
--- Here the second Group within the first group starts, where these fields show:
---- ¿Qué tipo de camas hay en la habitación? (same as above, + Tipo de habitación = 1)
==> This does not work, and it's due to this BUG:
https://toolset.com/forums/topic/after-repeatable-group-field-set-show-conditionit-is-not-to-save

Since the FIRST field in the FIRST repeating Field group (Tipo de habitación), does not save it's value, the subsequent conditions cannot work.
BUT, there is as well another BUG, where second, or deeper levels of Repeating Groups, do not respond to the condition (any) set to their Fields.
I reported that problem as well to the Developers.

I think this is exactly what you meant, correct?

BTW; the bug happens on all conditions, in all fields, if the Repeating Fields Group (RFG) is nested into another RFG, even if you use conditions from the SAME RFG.
I reported that in the same bug report to the Developers as well.

If you encounter other issues, please let me know in a new ticket too?

Thank you a lot

#912991

1) "I think this is exactly what you meant, correct?"

EXACTLY

2) "BTW; the bug happens on all conditions, in all fields, if the Repeating Fields Group (RFG) is nested into another RFG, even if you use conditions from the SAME RFG."

Correct. You just better defined (explained) issue.

3) "If you encounter other issues, please let me know in a new ticket too?"

Is it mean that my last question from last reply I must to ask in new ticket?

It is basically, to remind - If initial field of the post is in RPG (here, "Tipo de negocio"), ANY OTHER FIELD witiin post can be set as dependent on it values within conditional logic (so, all dependent fields became INVISIBLE). It is actually same (conditional logic within RPG), but also different issue.

P.S. Please, as I saw that developers are added to ticket after your report of bug, how much time appx can be expected for bug solution and fix (to know to plan)?