| Project: | Conditional Fields |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
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?
Comments
#1
You 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.
#2
#3
subscribe
#4
subscribe
#5
I 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.
#6
#7
Hi 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/
#8
it seems that my last post did not get the zip file correctly, here is again.
Dany
#9
Haven't tested this yet, but here's a patch of #8.
#10
its not working
#11
#12
This patches the whole file. I can't see what's changed. Can you reroll properly against latest dev? Thanks.
#13
Patch 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.
#14
Hi,
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?
#15
subscribing
#16
#14 This is the right issue: #357506: Compatibility with CCK 3x multigroup
#17
Just committed on 2.x-dev branch a big patch that allows multiple controlling fields per controlled field. Please test!
#18
Automatically closed -- issue fixed for 2 weeks with no activity.
#19
Hi,
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
#20
I also need to use an OR operator.
#21
Bumping this to the 7.x dev-version.
I can see around line 370 in the .module file:
// TODO: OR/XOR grouping of dependencies.Does anybody know if this is related to this feature?
#22
#21: Right, this is a planned feature, coming (hopefully) soon.
#23
subscribe
#24
subscribe
#25
subscribe
#26
subscribe
#27
Is this ever getting in?
Field conditional state from peem83 has this feature. Maybe borrow code from there?
#28
This 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?
#29
peterpoe can we can an update on this? What kind of work are we talking to get this support up and running.
#30
There 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.
#31
20 more dollars to the bounty! Field collection and Conditional fields should be fully functional and in the core!
#32
What 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
#33
I 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