Project:Conditional Fields
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

Hello everyone,

As i suggested before, think it could be nice if we can implement nested conditions. I see 2 ways:
hypothesis:
we have 3 fields
field_1 = {a1 ; b1; c1 }
field_2 = {a2 ; b2; c2 ; d2 ; e2 ; f2}
field_3 = {a3 ; b3; c3 ; d3 ; e3 ; f3 ; g3}
1st kind of condition: multi conditions based on the same field
IF field_1 = {a1 } => field_2 = {a2 || b2}
IF field_1 = {b2} => field_2 = {c2 || d2}
IF field_1 = {c2} => field_2 = {e2 || f2}

1st kind of condition: multi conditions based on the same field
IF field_1 = {a1} => field_2 = {a2 || b2}
IF field_2 = {a2} => field_3 = {a3 || b3 || c3}
IF field_2 = {b2} => field_3 = {d3 || e3 ||f3 ||g3}

Would you think that may be possible

Comments

#1

If I understand right, you are proposing:
1) That a controlled field can also be a controlling field at the same time.
2) That a field can be controlled by more than one field at the same time.

The 2nd feature is simpler, as it needs only upgrading of the javascript logic. It would be nice though if it were possible to set whether the controlling fields should be all triggered (AND), or just one of them (OR).

The 1st feature needs a bit more coding, as we have to avoid fields controlling their controller's controller (conditional loops!).

Implementing both these features would also probably require a new interface for the setup of the conditional fields, so that one can have a visual representation of the hierarchic structure.

We can start studying on this, but actual implementation should be probably postponed after the first official release of cf.

#2

Thank you for taking it into account. It's obvious such an enhancement can only begin after a fisrt official release

#3

Status:active» postponed

#4

I'd like to have this feature too..
But I think it could be enough just to have the first field passed as argument to the second one, so that you can use it to display allowed value with php: do you think it could be possible?

#5

Having the same problem. I would be also interesting in additional feature. Thanks

#6

#7

+ 1 who wants this feature :)

#8

if think the idea could be like "herarchical select" but for cck lisbox fields...

#9

After the first official release is out now - which is awesome :) - are there plans to realize this feature?
IMO the first approach of comment #1: That a controlled field can also be a controlling field at the same time. would be great/useful.

Regards,
Stefan

#10

subscribing - i agree that this would be a great feature that will allow lots of flexibility

#11

Title:nested conditions» Allow nested conditional fields
Version:6.x-1.x-dev» 6.x-2.x-dev
Status:postponed» active

Any contribution is welcome on this feature. It is a very big feature, so its priority is lower than other important and easier features for Conditional Fields 2.0, but I mark it as active anyway to attract attention.

#12

+1

#13

+1

#14

+1

#15

+1

#16

Uh, hey folks. I think this feature already exists. Perhaps on accident? I have a form doing all of these things and I haven't modified the code at all. I have:

1) Fields being hidden/shown by more than one controller.
2) Fields being hidden/shown by another field which is in turn hidden/shown.

I think all I did was start with the inner-most field and work out. And in selecting multiple controllers, I think I just ctrl-clicked in the drop-down. I don't remember whether I'm using 1.x or 2.x. Probably 2.x since I plan on modding it to handle controllers from other groups and auto-populating radios and checkboxes based on controllers' values and then disabling those checkboxes.

For those interested, the case study is this:

When a new physician begins working for my organization, the access to computer systems depends on where they work and with which group. Those two items are the controllers. The group will show/hide various fields based on the value from its drop down menu. There are six choices. The location will control which of the visible checkboxes are selected. Each checkbox is a different computer system the physician needs access to. Since those systems are required, the checkboxes will be disabled so they can't be deselected.

Of course, if I can work all of this out, I'll post a patch back. Wish me luck.

#17

rconstantine is right. As long as each controlling (parent) field comes after its controlled (child) fields in the "conditional_fields" table in your database, nested conditional fields are already possible. The problem is that this isn't really supported through the UI. Perhaps we should introduce something like weights to conditional field settings to allow to specify which field settings are executed first.

#18

Title:Allow nested conditional fields» Nested conditional fields
Status:active» needs review

Just committed to 2.x-dev a big patch which provides support for nested conditional fields. This means that a field can be controlled and control other fields at the same time!

Please test and report any bugs here.

Note: to avoid most problems with nested conditions, when a field is made controlled, all fields that it already controls are forced to share its controlled settings.
Example
A controls B
If I make C controlled by B, field A will be automatically set as controlling the field C with the same values as B.

This doesn't avoid every problem (you could always create a loop like A controls B controls C controls A...), but I think that it is enough to avoid confusion to admins.
Please share your thoughts on this if you think that more strict loop controls should be enforced.

#19

I forgot to mention: when installing the latest version (Jan 17), you have to clear the site's cache because the theme registry has changed.

#20

+1 subscribing

#21

subscribing

#22

There is a problem with the current implementation. Say you have four fields A, B, C, D that can each have values True or False. Using boolean logic, their conditions for display are set up as follows:
A = True
B = True
C = A && B
D = C

If you select A=True and B=True, C appears. If you then select C=True, D appears. Now the problem: If you select A=False, C is hidden as it should be, but D stays displayed.

Basically D is displayed based on the value of hidden field C. I don't think this is the desired behavior.

#23

First of all: Thank you very very much for providing support for nested conditional fields. This was a much needed feature.

I think threexk (#22) is right. The optimal solution is to generally hide fields if their controlling field is hidden. In threexk's example my workaround would be to set the default value of C to FALSE, but this is certainly not ideal, especially if the user first sets all fields to TRUE and then changes his mind and sets A to FALSE, which would lead back to the situation described in #22.

#24

#22
From what I know, the problem should only arise if you first set D as controlled by C, and after that you set C as controlled by A and B. If you do the reverse (setting first C as controlled by A and B, and only then D as controlled by C), D should automatically inherit the settings of C.
Could you please test if this is the case or it's another bug?

#25

Status:needs review» closed (works as designed)
nobody click here