Commit b52ab70 seems to have broken the functionality that reset dependent fields to their default values if the dependency isn't triggered.

When isset was changed to !empty on line 723 of conditional_fields_form_field_get_values(), it leads to the logic on line 750 getting triggered, leading to continue on line 754:

    if (!isset($field_values_location[$dependent['#field_name']])) {
      if (!empty($field['errors'])) {
        $untriggered_dependents_errors = array_merge($untriggered_dependents_errors, $field['errors']);
      }
      continue;
    }

Therefore, the default values do not get reset.

Previously, isset was true, event though it was an empty array, getting the nested value for $element['#field_parents']. Now, !empty is false, so conditional_fields_form_field_get_values() uses $element['#parents'] instead. The resulting $field_values_location arrays are very different, triggering the continue referenced above.

The ultimate impact of this is that an un-triggered dependency can get saved with values that should have been reset, which then corrupts the data that we're ultimately exporting.

Given the complexity of the code and my unfamiliarity with it, I'm not clear how to best approach a patch in this case. Any suggestions or help would be welcome. Thanks.

Comments

a-fro created an issue. See original summary.

a-fro’s picture

Issue summary: View changes