Hello,
in Generic Jammer, in function _jammer_generic_remove_element() from jammer_generic.module, the comparison is:

  if ($key == $element_id) {
    $value_array['#access'] = FALSE;
  }

But just after it calls itself recursively on children. On my Drupal this form as one child that is called "0" (the number, not the string).
Comparing 0 == "some string" leads to implicitly converting the string to number, which is equal to 0 when not a number, so 0 == 0 and many elements are removed in the form instead of just one.

Simply changing "==" by "===" is enough.
Or using explicit strings if ("$key" == "$element_id")

By the way if the element matches (setting #access to FALSE) does it makes sense to recursively check the children? This function should just return after matching, which would save a little time.

Regards.

Comments

  • naiduharish committed d7096ae on 7.x-1.x
    Issue #2849195 by gilles.brochet@free.fr: Bad comparison / implicite...
naiduharish’s picture

Status: Active » Fixed

Recursive check is done in the cases where we need to hide fields with field collections or child fields.

Fixed the issue.

Status: Fixed » Closed (fixed)

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