Has anyone else run across this issue. I'm working in Drupal 7. I've added several Dependent fields. They work fine in Firefox, Chrome, Safari...but they don't open as expected in IE. Any ideas?

Files: 
CommentFileSizeAuthor
#13 conditional_fields-IE9_fix-1373656-13.patch1.55 KBnielsdefeyter
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

Comments

sweimer’s picture

This might help. As I looked closer, I realized the Dependee field is a multi-selection list. The field is "Add Media" with options like "Add Audio" and "Add Image" ect. The field is set so more than one option can be selected. The Selected options then open media upload fields (for example...if "Add Audio" is selected, an "Audio Upload" field then appears.)

I'm guessing that allowing multiple selections on this dependee is the issue in IE since I have several other dependent fields that are not multi-select fields that are working fine in this same Content Type in IE

letsgokrogoling’s picture

I'm currently having the same issue; multi-select list, and two other dependent fields are shown and hidden based on which values are selected. It works fine in Firefox and Chrome, but not in Internet Explorer.

Has anyone else run into this?

jeff h’s picture

Yep; unlike your situations though this is happening for me with a drop-down list as the trigger field (ie the dependee). Works perfectly almost everywhere, even IE9. The problem is in IE 8 and earlier (I tested 7, didn't test 6).

The error I get in IE8's Console is:

SCRIPT65535: Unexpected call to method or property access.
jquery.js?v=1.4.4, line 114 character 479
jeff h’s picture

Status:Active» Closed (fixed)

I put a console.trace() at the right moment in jQuery itself and discovered that (in my case at least) this whole problem arose because of a different module entirely! For me it was the Field Group module (http://drupal.org/project/field_group) and there is an issue over there (http://drupal.org/node/1793184) that describes similar problems to this issue, and a solution.

The quickest fix for me was simply to upgrade from Field Group 7.x.1-1 to 7.x-1.x-dev. My Dependent Field problem vanished and everything works perfectly in IE 7+ (didn't test in 6 or earlier).

Even if your problem isn't due to Field Group, be very suspicious of any other javascripty modules you might have doing things on the same page. Check their issue queues for IE problems as well.

I'd be very interested to know if the two earlier posters on this issue had Field Group on the same page. I'm going to close this issue in the assumption they did, but please re-open it if you didn't.

dafeder’s picture

Issue summary:View changes
Status:Closed (fixed)» Active

I am having this issue in IE9 and it doesn't seem to be related to fieldgroup. It's not producing a Javascript error in the console, but no dependent fields display for me at all in IE9. I got some insight by reading this:

http://stackoverflow.com/questions/9794148/drupal-7-forms-api-conditiona...

I added a line of code at the end of conditional_fields_form_after_build() that re-sets the value in one of the #states arrays to be a string:

<?php
$form
['field_search_zip']['#states']['visible']['[name="field_search_by[und]"]']['value'] = "0";
?>

This makes it work in IE with no ill effects on Chrome. I'm a little mystified though why this doesn't happen for everyone... I assume there would be a lot more discussion around this if it happened on every site. I'm going to write a patch that will do this for all dependee fields but I don't quite understand what's going on here.

dafeder’s picture

Status:Active» Needs review
StatusFileSize
new1.19 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

Here is a patch that makes conditional fields work for me in IE9 by casting values as strings.

MrDaleSmith’s picture

StatusFileSize
new1.32 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

Ran into the same IE9 issue and the patch in #7 nearly worked - there was one extra value that needed to be cast as a string.

Have patched against 7.x-3.x branch - apologies if it's not correct: my first patch. Aw! Bless!

MrDaleSmith’s picture

Sorry - seem to have hidden the previous patch.

Jax’s picture

#7 worked for me too. Issue in IE11 with radios.

scott.whittaker’s picture

I ran into the same issue, using a "one of these values" from a list of options. As we only allow one value to be selected (radio buttons) rather than multiple values (checkboxes) I resolved the issue locally by changing my rules to use "has only one of the values" instead of "has any of these values". Of course it would be better for this patch to be rolled in so you don't need to do that, but this is a workable solution that doesn't require a patch.

huteb’s picture

Status:Needs review» Reviewed & tested by the community

#7 works for me too. I tried using only the "one of these values" option, which worked but not consistently (for a strange reason I could get it to work on my dev environnement but not on the staging server...). With the patch it works fine.

gachan’s picture

It also works fine for me.

Thank you.

nielsdefeyter’s picture

StatusFileSize
new1.55 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

We needed to combine patches #6 and #7 and that worked in IE 11.

Attached patch applies to 7.x-3.x .

Edit: for clarity, attached patch (#13) is the combined patch of #6 and #7.

nielsdefeyter’s picture

bisw’s picture

I have combined both patch #6 and #7 and it works fine for me.
Thanks.

peterpoe’s picture

Status:Reviewed & tested by the community» Needs work

Sadly, values can be arrays, we can't just cast them as strings like this.

Anybody’s picture

Well this problem still exists and breaks even the latest version of IE. The dependent fields will never show up there. That's why I'll set up the priority.

As stated out in #16 the patched above don't work for multiple value fields which breaks functionality even more...

CURRENT WORKAROUND:
Use "has only one of the values" as written in #10.

Anybody’s picture

I've had a look at this and finally I'd suggest the following:

1. This bug should be fixed at FAPI #states directly, see #1962800: form #states not working with literal integers as values in IE8 (and higher?)!

2. Furthermore the patch above is nearly complete, if you need a quickfix you should use the following for the values array:

<?php
elseif ($options['values_set'] == CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND) {
          if (
count($options['values'] > 1)) {
            foreach (
$options['values'] as $tmpkey => $tmpvalue) {
             
$options['values'][$tmpkey] = (string) $tmpvalue;
            }
          }
         
$values[$options['condition']] = count($options['values']) == 1 ? $options['values'][0] : $options['values'];
        }
?>

If someone would like to, please create a final patch from that if the module maintainer will not wait for the problem to be fixed in core (which issue is open since 2 years!)