The implementation of Drupal.CTools.dependent.inArray is incorrect: testing if undefined is in an array will always return true.

This is because the first test performed is if(array[array.length] == search_term) and array[array.length] is always undefined.

Attached is a patch to correct the behaviour.

This bug means that form elements which are dependent on radio button values will incorrectly default to displayed if the radio button group has no default value. This bug was previously reported here:
#630982: Dependent: Form items don't hide if nothing is selected in the radio item they depend on (e.g. no default_value)

The patch in that report has been implemented in the 7.x branch but is not in the current 6.x release. It successfully works around the problem but does not fix the root cause, which this patch does.

inarray.patch333 bytesDraknek
Members fund testing for the Drupal project. Drupal Association Learn more


EclipseGc’s picture

Status: Needs review » Reviewed & tested by the community

Freaking amazingly freaking freaking awesome. In short "YES PLEASE".

This fixes issues I've been running into for a very long time and it is greatly appreciated.


merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x and 7.x branches and pushed.

Status: Fixed » Closed (fixed)

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