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.
Comment | File | Size | Author |
---|---|---|---|
inarray.patch | 333 bytes | Draknek | |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedFreaking 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.
Eclipse
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to 6.x and 7.x branches and pushed.