Problem/Motivation
Note: The original description (below) used a different combination of field types but a simple Select field and Text field illustrate the problem nicely.
Steps to Reproduce
- Start with clean install of Drupal 7.36 and conditional fields 7.x-3.x-dev (http://simplytest.me/)
- Add an integer list field (Select Field) to the Article content type with options: 1, 2, 3
- Add an integer text field (Text Field) to the Article content type
- Add a dependency: Text Field is filled with a value when Select Field has value "1" (Screenshot 1)
- Enter "1" for "Fill field with a value effect option: value"
- Check "Restore previous value when untriggered"
Expected result
- Text Field value is set to 1 when Select Field is "1"
- Text Field value is set back to "4" when Select Field is "2"
Actual result
- Text Field value is unchanged when Select Field is "1" (Screenshot 2)
Original report by StG
Hello,
I'm not totally sure: wheter it's a bug or it's just a user error: The entity is a node, the dependee is a simple true/false field, the dependent field is a list with several textual options. I'd like to fill this field with a value when the dependee is checked, thus I set the condition to 'value', the input mode to 'insert value form widget' and I checked to only option. If I set the form state of dependent to visible or invisible everything works as intended, the dependent field appeares or disappears as the dependee checked. But if I chose the 'filled with a value' form state (that's what I actually need) nothing happens. I added to the value field the 'key' of the desired list item.
Comment | File | Size | Author |
---|---|---|---|
#16 | filled_with_a_value-2142691-16.patch | 1.03 KB | draenen |
#14 | Screenshot1.png | 116.17 KB | draenen |
#14 | Screenshot2.png | 105.16 KB | draenen |
Comments
Comment #1
StG CreditAttribution: StG commentedReason of edit: typos
Comment #2
Rob de Koter CreditAttribution: Rob de Koter commentedI have the same problem, if the "Dependent" field hat the value "10" the "Dependee" should get the value "12", nothing happened.
If I change the "dependee" from "Filled with a value" to "Hide" all works fine.
Just to make sure I tried this on an other Drupal 7 install and a Linux instead of a Windows server unfortunately the result was the same.
I am wondering if the browser or the OS could have something to do with it.
I just installed a fresh version of Drupal 7.26 with as only extra module the "Conditional Fields" module, unfortunately it still does not work: Acquia Dev Desktop and IE 11 and Firefox 26
Comment #3
johnhorner CreditAttribution: johnhorner commentedI'm finding the same thing. Other options work, e.g. "visible when dependee has a certain value" or "disabled when dependee has a certain value", but not the "filled when dependee has a certain value" option.
Comment #4
joco_sp CreditAttribution: joco_sp commentedHas anyone found the solution for this?
Comment #5
bourgeoy CreditAttribution: bourgeoy commentedI am still having this issue, hoping for a solution! None of the fixes I've read about so far have helped...
Comment #6
j4 CreditAttribution: j4 commentedI am also facing this issue in a brand new installation. Some help please!
Duplicate of https://www.drupal.org/node/2270775
Comment #7
dstorozhukHave the same problem. Looks like the "filled with a value" doesn't work.
Comment #8
Maurice M. CreditAttribution: Maurice M. commentedIm also trying to do this, doesn't work.
Comment #9
kutagh CreditAttribution: kutagh commentedHello,
We wanted to utilize this feature as well, but ran in the same issue. I have been asked to investigate this issue and if possible to fix it.
Unfortunately, I have been unable to pinpoint the location of the code implementation for the feature to fill a value in the dependent (or to empty it), which leads me to believe that this feature has not been implemented whatsoever.
It is currently unlikely that I will be implementing this feature, but I do hope that someone will.
Comment #10
jeramy CreditAttribution: jeramy commentedSame issue. I am a bit surprised since this seems pretty fundamental. Seeing there has not been a commit on this module in a year, my hopes are not high for a resolution though. Has anyone found an alternative?
Comment #11
elgandoz CreditAttribution: elgandoz commentedApparently JQuery update (in my case 7.x-2.5) breaks CF. Disabling it solved this issue. See https://www.drupal.org/node/2122619
Comment #12
damianpollard CreditAttribution: damianpollard commentedHi elgandoz. I am having the same problem and I already have JQuery update disabled. Do I need to uninstall JQuery update to fix the problem?
Comment #13
funkeyrandy CreditAttribution: funkeyrandy commentedsame issue here with our without jquery update
Comment #14
draenen CreditAttribution: draenen commentedAdded steps to reproduce.
Comment #15
draenen CreditAttribution: draenen commentedFurther investigations showed that "fill with a value" is implemented as an effect (like fade in/out etc) and all effects seem to be broken it the latest release. See #2466187: Effects doesn't work
Comment #16
draenen CreditAttribution: draenen commentedI tested this patch with the steps in the description. The issue is that Drupal states.js does not bind the 'empty' state by default so the fill effect was not triggered.
Comment #17
jwineichen CreditAttribution: jwineichen commented#16 patch worked for me!
Comment #18
bijbij CreditAttribution: bijbij commentedHi dear draenen
I have used your patch(#16)
But it is not working for me even after applying #16 patch .
help me please.
Comment #19
draenen CreditAttribution: draenen commentedbijbij, could you tell me what field types you are using in the dependency?
For example: "a text field is filled with a value when a select field has a value".
Comment #20
Darshi Shah CreditAttribution: Darshi Shah commentedHi
#16 dont work for me. I want it to fill value in one select list based on another. I tried using text field as well but it doesnt work.
- Darshi
Comment #21
funkeyrandy CreditAttribution: funkeyrandy commentedim using two integer text fields....text field 1 should be set to 55 if textfield 2 is set to 99....no change, patch #16 implemented...jquery turned on as well as disabled
please help
Comment #22
MrPeanut CreditAttribution: MrPeanut commentedPatch from #16 applies cleanly, but does not work for me either.
In my case, I am trying to set the value of a Long text field that is dependent on the value of a List (text) field. (For example, if the I choose "Service" in the select list, it puts "Please enter your service request" in the long text field.)
Comment #23
agsh CreditAttribution: agsh as a volunteer commented#16 patch worked for me.
jQuery update enabled (jQuery version by default: 1.10).
Comment #24
eigentor CreditAttribution: eigentor commentedFor me #16 worked.
I changed the two lines manually, since the patch did not apply.
No Jquery update installed in my case.
Comment #25
ramdhanh CreditAttribution: ramdhanh commentedVote for #16. Applied that one and solved my issue. Thanks.
Comment #26
cosolom CreditAttribution: cosolom commented#16 worked for me too
Comment #27
GAMe CreditAttribution: GAMe commented16 didnt work for me either Im trying to display a text field if a link field has a value. :-(
Comment #28
eigentor CreditAttribution: eigentor commentedJust a tip for those that need some advanced conditional fields features and sometimes hitting their head against a brick wall: One can perfectly - and sometimes more flexibly - code this functionality by hand.
I once had to to this because conditional fields caused some weird error and I was suprised how well it worked.
The trick is to not set fields as required and build a validation function oneself.
The conditional fields module does it the other way round by catching all the error messages thrown by required fields and unsetting the messages which leads to not making the fields required. This more complicated than not making a field required in the first place.
So in your validation function, you can set the field as required and do all kinds of fancy stuff.
While required fields are not the topic of this issue it is the problem that normally causes the most headache when you try to not use the module while getting the same functionality.
The #states property of forms of the forms api comes in handy: it allows to check if a field is checked or contains a certain value, which is Javascript, from php code.
https://api.drupal.org/api/examples/form_example!form_example_states.inc...
Comment #29
jhoffmcd CreditAttribution: jhoffmcd commentedSo I thought I had this working, but when pushed to production, something is different and it's not working. When I run the site locally, everything is fine and the patch does work. There is some other factor that is causing this to work/not-work for everybody. If I find it I'll try and refactor a patch and load it up.
FYI both env run jQuery 1.10.2.
Comment #30
hondaman900 CreditAttribution: hondaman900 commentedAny updates on this issue? I'm stuck and have an entityForm where, depending on the select list option selected, a value is put in another textbox integer field. As stated by others above, this doesn't work (though make visible with same conditions does work).
Any solutions/workarounds for this...?
Comment #31
Mr. Red CreditAttribution: Mr. Red as a volunteer commented#16 patch worked for me.
jQuery update enabled (jQuery version by default: 1.10).
Comment #32
pamelalies CreditAttribution: pamelalies commentedInterestingly, I got the patch to work if I added the first line - the additional bind state, but left the second line unchanged (that is, left is as: if (typeof oldValue === 'undefined' || field.val() !== e.effect.value) ). This seems logical to me - but I'm confused as to how it works for some people with the change to that second line added.
I looked at the code in the conditional_fields.js downloaded file for the 7.x-3.x-dev version of the module, and that's the way it was in there (First line changed, but not the second) - so I thought I'd give it a shot, and sure enough it works!