Currently, if a dependent field has more than one dependee, the dependency is triggered only if all its dependees satisfy the condition.
Users should be able to group dependees by dependend and decide the grouping logic (AND, OR or XOR).
Original Issue
It is a stated limitation of Conditional Fields that multiple controller fields do not work. Currently it will let you specify multiple controller fields for a single field. However, the controlled field is activate/inactive according to only the last controller field that was toggled.
e.g., I have a controlled field and two radio-buttons controller fields:
Controller 1:
( ) Red
( ) Green <-- Controlling value
Controller 2:
( ) Red
( ) Green <-- Controlling value
I now perform the following actions in sequence.
1. Choose Green for Controller 1, the controlled field displays. GOOD.
2. Choose Green for Controller 2, the controlled field is still displayed. GOOD.
3. Switch Controller 2 to Red, the controlled field is hidden. BAD. (Since Controller 1 is still Green, I would expect the controlled field to still be displayed.)
Proposed behavior:
Multiple controller fields function as a logical OR for determining whether the controlled field is displayed. e.g., (Controller 1) || (Controller 2) || ... || (Controller n). Currently whether to display or hide is decided just according to the state of the last-recently-toggled controlled field.
(Maybe this could be implemented with an up/down counter: Whenever a controlled field's controlling value is selected, increase the up/down counter. When a controlling value is deselected, decrease the up/down counter. When the counter hits 0, hide the controlled field.)
Is there anything I'm not considering here? Are there any other issues that make multiple controller fields hard to implement?
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | conditional_fields.orxor_.patch | 26.11 KB | Frando |
| #9 | multiple_controller_fields.patch | 103.24 KB | mitchell |
| #8 | conditionnal_field_patch.zip | 11.6 KB | dan_theman |
| #7 | conditionnal_field_patch.zip | 11.6 KB | dan_theman |
| #5 | conditional_fields.js.txt | 4.71 KB | loze |
Comments
Comment #1
peterpoe commentedYou correctly described the javascript part. To implement the feature, we should also change the logic of node view.
Idea: it would be nice to also let users define the logical operator: AND / OR.
Comment #2
peterpoe commentedComment #3
loze commentedsubscribe
Comment #4
loze commentedsubscribe
Comment #5
loze commentedI reworked the javascript to allow multiple controlling fields.
however, I didn't touch the node view logic or letting the user define the logical operator (yet).
I'm not sure if this is the approach that you want to use, and it can probably be optimized.
What this does, is on each field change, loops through all the controlling fields and sets a flag for the controlled field, if any one of the controlling fields values should trigger the controlling field. Then it calls showField and shows / hides the controlled Field depending on the flags value.
It's working for my limited purpose, and should for the above scenario.
just replace the conditional_fields.js with this file.
I've only tested it with d6.
Comment #6
loze commentedComment #7
dan_theman commentedHi there,
For my application the file from loze did not the job, so i implemented the multiple controller functionnality. I didn't tested exhaustivly, but il should work in most of the situations. It works for sure for my application! The logic between controlling field is a logical AND. For exemple if you have :
A field
choice 1 ()
choise 2 () -->controlling value
B field
Choice 3 ()
Choice 4 () -->controlling value
C field (controlled field)
Choice 5 ()
Choice 6 ()
the field C will be showed only if the field A is 2 AND field B is 4
So to apply the patch just replace the two following files in the conditionnal field version 6.x-1.x-dev from 2009-Feb-02.
I left some french comments in the code in case it can help.
Hope this will help somebody!
Dany
Sonsored by :
Interconnect Telecommunucations
Batisseurs de Reseaux / Network Builders
http://www.interconnectinc.qc.ca/
Comment #8
dan_theman commentedit seems that my last post did not get the zip file correctly, here is again.
Dany
Comment #9
mitchell commentedHaven't tested this yet, but here's a patch of #8.
Comment #10
kaay commentedits not working
Comment #11
mitchell commentedComment #12
peterpoe commentedThis patches the whole file. I can't see what's changed. Can you reroll properly against latest dev? Thanks.
Comment #13
geraldito commentedPatch of #9 is not working for me but substituting conditional_fields.js and conditional_fields.module files with files from zip of #8 works fine and makes multiple controller fields working for me.
Comment #14
x_magnet_x commentedHi,
I use Drupal 6 with CCK2 + Multigroup (and Services/AMFPHP) for a Flex based Page.
In my Flex Page I have a created a Block Component, because I need to combine Text, Images and Videos.
The Block Comnponent has nothing to do with the Block Module in Drupal!!!
The order of these Blocks is unsorted, so the User for example can produce a Text Block wich is followed by a Image Block or a Video Block and so on.
Example:
Text, Image, Video, Image, Text, Video...
or
Image, Text, Text, Video, Video, Image, Image, Text....
In Drupal I have a Content Type with a Multigroup which includes a Slecet Box (so the User can choose the Block Type (Text, Image, Movie)), a Text Field (FCK), a Image Upload Field (for Image Block), and a File Upload Field (for Movie Block).
The Multigroup is set to unlimited, so the User is able to add unlimted Blocks!
The combination with the Service Module and the multigroup works great, but the Usability is not as good, because all "Block" Types are always displaying. I need to hide the additional fields. So I found the Conditional Fields Modul, which is what I searched for! But it does not work. Is there a alternate Module which is working with Multigroups? Or a Multigroup Patch for the conditional Field?
Comment #15
Bilmar commentedsubscribing
Comment #16
peterpoe commented#14 This is the right issue: #357506: Compatibility with CCK 3x multigroup
Comment #17
peterpoe commentedJust committed on 2.x-dev branch a big patch that allows multiple controlling fields per controlled field. Please test!
Comment #19
mysterwii commentedHi,
Thanks for this great module but I have a problèm.
I would like select C controlled field if you choose a choice in A field OR B field.
C field is the final answer for the 2 choices.
A field
choice 1 ()
choise 2 () -->controlling value
B field
Choice 3 ()
Choice 4 () -->controlling value
C field (controlled field)
Choice 5 ()
Choice 6 ()
The field C will be showed only if the field A is 2 OR field B is 4.
Could you help me ?
Thanks
Mysterwii
Comment #20
lindsayo commentedI also need to use an OR operator.
Comment #21
askibinski commentedBumping this to the 7.x dev-version.
I can see around line 370 in the .module file:
Does anybody know if this is related to this feature?
Comment #22
peterpoe commented#21: Right, this is a planned feature, coming (hopefully) soon.
Comment #23
drupov commentedsubscribe
Comment #24
chris pergantis commentedsubscribe
Comment #25
somanyfish commentedsubscribe
Comment #26
bshensky commentedsubscribe
Comment #27
Fidelix commentedIs this ever getting in?
Field conditional state from peem83 has this feature. Maybe borrow code from there?
Comment #28
ydnar79 commentedThis feature would be of GREAT benefit in many situations.... and from the age of this post and the other comments on here, it appears that I am not alone in this assessment.
So any word on adding this functionality?
Anyone have any success so far?
Comment #29
bryancasler commentedpeterpoe can we can an update on this? What kind of work are we talking to get this support up and running.
Comment #30
bryancasler commentedThere is another issue I'm interested in resolving that is dependent upon this issue being resolved first.
#1303862: Conditional fields has no effect on additional field collections
Over there I posted...
If you're interested in tackling both issues, please take a look.
Comment #31
Rhodungeon commented20 more dollars to the bounty! Field collection and Conditional fields should be fully functional and in the core!
Comment #32
bryancasler commentedWhat I'm trying to accomplish with Conditional Fields will most likely be solved by another model. For that reason I am removing this bounty.
Ref: #1067308: Integration with field_collection
Comment #33
LTech commentedI would like to show a field C if field A and/or field B and/or field C are filled.
Is this becoming an option with conditional fields? I'm not following the threads 100%. Please can you clarify.
Thanks
Comment #34
Frando commentedThe attached patch makes conditional_fields (D7) support OR and XOR conjunctions in addition to AND for multiple dependencies that point to the same dependent field.
For each dependency, under "Advanced dependency settings", you can select whether the dependency should belong to the AND, OR or XOR group. The default is AND, so nothing changes there. The three groups are ANDed togther, so you can easily create something like:
Show my_dependent_field if field_master_trigger is set to 1 and either field_condition_1 is set to 5 or field_condition_2 is set to 6, by selecting AND for the field_master_trigger dependee and OR for the two other dependees.
The patch works both on edit (states api) and view (server side evaluation) pages.
The patch also updates the states.js fork to the most recent version (which is also going to be included in Drupal 7.13). The conjunction groups weren't working properly with the older fork included in conditional_fields.
This patch is sponsored by Xarxa Media GmbH
Comment #35
bryancasler commentedThis is fantastic Frando, can't wait to test it. I'm not sure if you've seen this, but another user posted a patch for Conditional Fields support two days ago. I don't know if either patch can benefit from one another, but I wanted to point it out. #1464950: Support for multiple "Field collection" and "Multifield" fields
Comment #36
bryancasler commentedApplying the patch against the latest git pull results in this when trying to patch "js/states.js"
Comment #37
klonosIf you're also using the latest 7.x-2.x-dev of jQuery Update, it could be #1448490: Remove the states.js overwrite as it was fixed upstream that was recently fixed or it could be #1239930: states.js appends span.form-required to every label of a dependent field for core, but I don't think it has a patch against D7 yet.
Comment #38
bryancasler commentedAfter enabling the module with the patch I'm getting...
Comment #40
Frando commented@animelion:
Hm - that's strange, for me the patch both applies cleanly and I am not getting any Warnings. Maybe you checked out a wrong branch of conditional fields? The patch is for 7.x-3.x.
Comment #41
bryancasler commentedThanks Frando, I had just pulled the most recent commit in git. I'll give this another go.
Comment #42
segana commentedHi Frando!
Thanks for taking the time to create this patch as this is functionality I desperately need in conditional fields. I do have an issue however.
When I try to apply the patch, I get the following in Terminal (I use OSX).
Any idea what I need to do to apply your patch?
Kind regards,
Matt
Comment #43
kimu commentedThe patch includes changes to different files. As you see the prompt ask you to point which file you want to patch.
In that point of the procedure you have to write includes/conditional_fields.admin.inc.
It's enough to see the line which starts with |diff --git to see which file should be targeted.
Comment #44
segana commented@kimu
You are a champion! thanks for the help. I'll go have a shot at that now :)
Comment #45
kimu commented@Frando
thanks for sharing your work. Sadly, in my case this patch doesn't works and makes things worse.
As example:
I've 2 checkboxes, if the first is checked the second must be disabled. In the second is checked the first must be disabled. This mutual condition worked with the module, It stopped working applying the patch. These fields have only this condition, so there aren't interactions with other conditions.
I've seen other things stop working when the patch is applied. At the moment I don't have much time to go with massive tests, sorry for that, otherwise I would have provided more feedbacks.
Good effort anyway, probably it just needs further testing and small fixes to work correctly.
Comment #46
socialnicheguru commentedthe patch doesn't apply at all using "git apply"
it applies but not cleanly using "patch -p1 <"
Comment #47
3rdLOF commentedAlso fails in 4 out of 11 hunks againts the latest DEV version
Comment #48
peterpoe commentedCommitted!
I updated the patch to current dev with some visual indicators added in the dependency overview tables to show the operator of grouped dependencies.
Many thumbs up and thanks to Frando for doing 99% of the work on this 4 years old issue.
If you find problems with the implementation, please don't reopen this issue, but file a new one.
Comment #50
pfhsmj0 commented--Deleted --
Comment #50.0
pfhsmj0 commentedNew issue description for Conditional Fields 3 (D7)