I have one question. Does this module work with image fields? I can not get it run.
I want that one imagefield is hide if another has a value.

Thanks for any help!

Best regards

Members fund testing for the Drupal project. Drupal Association Learn more


peterpoe’s picture

Status: Active » Fixed

Dependent image fields work. You can read the new documentation to check that you got everything right: http://drupal.org/node/1704126

fraweg’s picture

Thanks a lot for your fast answer!

Best regards

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jfarry’s picture

Status: Closed (fixed) » Active

Hi Guys :)

I'm experiencing a bit of a problem between Conditional Fields and Image Field uploads in Drupal 7 as well. I've read the guide and have tried quite a few different permutations of options, but so far can't seem to achieve what I'm after.

I have two fields, one is an embedded media (file) field and an Image field. I want one to disappear when the other is filled. This works fine if I start to fill out the embedded medial field, the Image field disappears no problems, but if I upload an image through the Image field, the embedded media field doesn't disappear. I've tried setting the selectors to various form elements for the image field as well, but with undesirable results. If I set the selector to the image field Upload button, the embedded media field is constantly hidden. If I set the selector to any other form element of the image field, the embedded media field never disappears. I've also tried setting the dependee action to Focus and targetted the Submit button with the selector, but that doesn't remove the embedded media field either.

One more thing, if I set the image field to disappear and be emptied when the embedded media field is filled, the image field itself is not emptied, but the image upload button has its text removed. This shouldn't be a problem when I can get the other field to disappear, just thought I'd add it as a side note.

I feel like I'm missing something small and stupid, but I've changed so many thing now that I don't know what could be left, lol.

Thank you for your time :)

liquidcms’s picture

Category: support » bug

i am also pretty sure that this does not work with image fields as the Dependee: http://screencast.com/t/FqtLfeJDM5YN

Jason Dean’s picture

I'm also unable to use an image field as a dependee. The dependent field shows regardless.

alpho81’s picture

Same problem here. I'm also unable to use an image field as a dependee.

fonant’s picture

Issue summary: View changes

I have a need to only show a field if there is one or more images uploaded into a multiple-value file / image field. I can't get it to work, the dependent field is always shown, even when no images have been uploaded. Would be nice if the "Empty" test worked for a multiple-value file field with no files.

chrisgross’s picture

For anyone still struggling with this, yes this is possible without a patch. The problem seems to be that the image field is not correctly targeting the DOM object that is given a value when an image is chosen. To do this, we simply change the jQuery selector and make sure that we are checking the value attribute of that element, remembering that when the field is empty, the value is "0".

Configure the condition like this:

image field dependee value

And the Advanced Context Settings like so:

image field selector value

For the selector, I've chosen a class that matches the class of the field element/DOM object that contains the value. This will change depending on the name of your field, but you can use any variant of selector that matches this element. If you are only using one image field per bundle, you can probably even get away with just '.fid' instead. I tried using the language and key tokens to select the name attribute of the element, but I couldn't get it to work.

The above example is assuming the form state context is set to "visible". You should be able to make this work in other configurations, but this is the general process.

chrisgross’s picture

chrisgross’s picture

Just updating the file in #9 to switch the logic on the fid selector. This value will actually match the fid, so it just needs to NOT be 0. There is another hidden field with no unique class that seems to only store a 1 or a 0, but as stated in comment #9, I have not been able to get this name selector to work with the tokens. If anyone else has better luck, let me know, but this solution still works.

cotillardq’s picture

The only way I was able to make it work was by using the name value:
input[name='field_hero_image_lg[und][0][fid]'] in the Advanced Context Settings

ray17n’s picture

#12 worked for me, using a similar value, thanks.

bpadaria’s picture

#12 worked for me as well with combination of #11

Thanks for sharing!!

Yogesh Pawar’s picture

I my case i have a multiple paragraph layers in which i have to show/hide one radio button field on image upload.
how can i achieve this kind of functionality @chrisgross & @cotillardq