Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I was wondering if it is currently possible to show the controlled field if any of the controller fields is selected.
Essentially show if 'a' OR 'b' OR 'c' etc
At this moment if I select a, b, c as controlling field d, all 3 have to be selected for field d to show.
Thank you very much.
Comment | File | Size | Author |
---|---|---|---|
#15 | conditional_fields_boolean_or.patch | 22.67 KB | threexk |
#16 | conditional_fields_boolean_or.patch | 22.67 KB | threexk |
Comments
Comment #1
rburgundy CreditAttribution: rburgundy commentedComment #2
peterpoe CreditAttribution: peterpoe commentedNot at the moment.
#718138: Per field settings (instead of per content type) must be solved before we can add this kind of logic.
Comment #3
YK85 CreditAttribution: YK85 commentedHello peterpoe,
Thanks always for your great work.
Do you have an idea of when this feature may be available? I really need this OR functionality and looking for workarounds without any luck.
Thanks!
Comment #4
peterpoe CreditAttribution: peterpoe commentedYou would have to modify both the javascript and the nodeapi function to make it work with OR. I will work on per field settings in the following days, then this should come right after.
Comment #5
YK85 CreditAttribution: YK85 commentedawesome! thanks for the kind explanation.
i look forward to your work =)
Comment #6
Bilmar CreditAttribution: Bilmar commented+1 subscribing
Comment #7
locomo CreditAttribution: locomo commentedsubscribe
Comment #8
YK85 CreditAttribution: YK85 commentedpeterpoe - I wanted to let you know about #735528: FAPI #states: Fix conditionals to allow OR and XOR constructions
May I kindly ask if we would be able to expect the OR functionality in the coming weeks?
Thanks!
Comment #9
robby.smith CreditAttribution: robby.smith commented+1 subscribing
Comment #10
threexk CreditAttribution: threexk commentedSubscribe. Two years later, I'm still in need of a way to OR controlling fields. :) I may try to work a patch in the coming weeks to support either AND or OR.
Comment #11
robby.smith CreditAttribution: robby.smith commentedthreexk - it would be AWESOME if you could create a patch to allow OR functionality! I will be first in line to do extensive testing with feedback.
Comment #12
Bilmar CreditAttribution: Bilmar commentedHi threexk,
I was wondering if you were able to develop 'OR' functionality by any chance?
Would really appreciate your support.
Thanks!
Comment #13
fschaff CreditAttribution: fschaff commentedSubscribe
Comment #14
Jonasvh CreditAttribution: Jonasvh commentedalso interested
thanks
Comment #15
threexk CreditAttribution: threexk commentedHere is a patch to add support for ORed controllers. For any controlled field, you can choose under 'Conditional fields settings' whether:
1. All the controlling fields must have trigger values selected for the controlled field to be displayed (boolean AND).
2. Any controlling field must have a trigger value selected for the controlled field to be displayed (boolean OR).
The patch is not suitable for commit--it works in a crude way and it duplicates a lot of code--but I'm posting it in case anyone really needs this functionality. I'm hoping to make a second pass in the future, now that I understand the code better, to try to come up with something worthy of consideration for commit.
Installing:
1. Patch DRUPAL-6--2 branch.
2. Run update.php.
Uninstalling:
1. Restore files from released version of module.
2. Delete 'boolean_operator' column from 'conditional_fields' table.
Known limitations:
1. Nested conditional fields don't work with OR in this patch. Nested conditional fields should still work as before with AND though. [Example: If you have fields A and B that control a field C, and C controls another field D, things will not work properly if A and B are using the OR operator.]
2. You cannot combine AND and OR to construct more complicated boolean logic for deciding whether a field should be shown. [Example: For a controlled field D with three controlling fields A, B, and C, you cannot do something like D = A AND (B OR C).]
If you try this patch and run into any other problems besides those two, I'd be interested to know. Conditional groups should work, but I have not tested them. Orphan settings might work, but I haven't tested them either.
How the patch works:
It adds a column 'boolean_operator' to the 'conditional_fields' table. Every field gets a boolean operator, AND is the default. Basically anywhere in the code where it checks that all the controlling fields have trigger values selected, I added a conditional for OR that checks whether any of the controlling fields have triggered values selected.
Thanks, peterpoe (and other contributors), for writing such good code that I was able to figure it out enough to get this somewhat working (I think).
Comment #16
threexk CreditAttribution: threexk commentedWhoops, the previous patch did not default existing fields to AND (I accidentally attached an old one). Use this one:
Comment #17
robby.smith CreditAttribution: robby.smith commentedGreat work!! I will definitely be testing this soon and will report back if I come across any issues besides the limitations mentioned. It would be really awesome to see this further developed and committed to 2.x-dev. However, I read in another post that peterpoe is working on a 3.x branch that will hopefully have this functionality and others. I hope peterpoe will be able to comment on your code that allows boolean_or functionality. Thanks!
Comment #18
YK85 CreditAttribution: YK85 commentedI was wondering if any has had any further process with this feature?
Thank you
Comment #19
robby.smith CreditAttribution: robby.smith commentedhaving this feature in Conditional Fields shipped would be great!
Comment #20
benone CreditAttribution: benone commentedsubscrrrrr
Comment #21
bcrogers CreditAttribution: bcrogers commentedVery interested in this feature.
Comment #22
KevinKydd CreditAttribution: KevinKydd commentedI have been using this patch on my site and it works well for the most part. The one flaw that is very glaring is that if I set a field as a controlling field for multiple other fields if I go back and change that field's own controlling field, the fields it controls inherit the same controlling fields. I know that sounds confusing but it looks something like this:
Field 1
--Field 2
----Field 3
----Field 4
----Field 5
Now if I change Field 2's controlling field to Field 1 AND Field 6 after I already created Field's 3-5, it will set Fields 1 and 6 as controlling fields for Fields 3-5 even though I didn't try to do that.
Also, my site has become very dependent on the OR functionality at this point. Will there be a commit on this issue any time soon? If I update to the newest beta will this patch need to be reinstalled?
Comment #23
chuckbar77 CreditAttribution: chuckbar77 commentedGreat module! Would love to see this feature in D6 before D7!
Comment #24
YK85 CreditAttribution: YK85 commentedHi peterpoe, I was wondering if you may have had time to develop the 3.x version with this feature? Thanks!
Comment #25
rburgundy CreditAttribution: rburgundy commentedbump
Comment #26
droid19 CreditAttribution: droid19 commentedSubscribe
Comment #27
pedrospJust arrived to this patch, and seems not working anymore with the current release.
The Ui on the field form seems ok, but not the behavior.
Any chance to have an update to this patch, or even the standard release ?
Thanks.
Comment #28
ydnar79 CreditAttribution: ydnar79 commentedBy any chance can this patch be modified so it can be used with the D7 version? I know that the interface has changed a LOT.... but I have not had a chance to check the code yet..... So I just figured that I would ask.
Comment #29
WorldFallz CreditAttribution: WorldFallz commentedanyone get this working yet or have an updated patch for d6? I'm probably going to work on this feature, but I'd like to start with the most current info. thanks.
Comment #30
virgo CreditAttribution: virgo commentedsubscribe
Comment #31
peterpoe CreditAttribution: peterpoe as a volunteer commented