I've found using regexp to be the easiest way to make this module work. One field can have multiple dependencies like this: "value1|value2|value3".

This works great in all browsers. Except IE. I read the issue #1373656: Dependent fields don't open in IE and here the solution seemed to hover around casting options to strings. I've decided to open a new issue because I'm not sure my problem is the same. My patch solves the issue *I* had in IE, but it had nothing to do with casting options to strings, but rather that IE couldn't handle multivalued regexps.

I've implemented conditional fields in my modules install file along with fields. I've looked at how conditional field arrays look when making the through the GUI, and use conditional_fields_dependency_insert and conditional_fields_dependency_update to register my conditions to each field.

I use lots of radios and before my patch, the #states array looked like this:

[#states][visible][name="blabla"][0][value][RegExp] = value1|value2

This worked flawlessly in all browsers but IE.

After applying the patch, it looks like this:

[#states][visible][name="blabla"][0][value] = value1
[#states][visible][name="blabla"][1][value] = value2

And now it works in all browsers including IE.

I'm not sure where the bug really is. It might be that IEs javascript engine doesn't handle RegExp the way other browsers are doing it. Perhaps this is a bug that belongs in upstream, jQuery or whatnot, I don't know. Perhaps someone else can dig further. I'm just happy that my patch works.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

odegard’s picture

odegard’s picture

odegard’s picture