Problem/Motivation
TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::elementAddProperty(): Argument #1 ($element) must be of type array, null given, called in /app/docroot/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php on line 194 in Drupal\conditional_fields\ConditionalFieldsFormHelper->elementAddProperty() (line 843 of modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).
Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependeeFields(Array, NULL, Array, Array) (Line: 111)
Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependentFields() (Line: 85)
Drupal\conditional_fields\ConditionalFieldsFormHelper->afterBuild(Array, Object) (Line: 187)
conditional_fields_form_after_build(Array, Object)
call_user_func_array('conditional_fields_form_after_build', Array) (Line: 1084)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | conditional_field_fake_form_filds_error--4.patch | 502 bytes | blade_ukraine |
| #2 | conditional_field_fake_form_filds_error.patch | 580 bytes | blade_ukraine |
Issue fork conditional_fields-3438997
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
blade_ukraine commentedComment #3
blade_ukraine commentedComment #4
blade_ukraine commentedFixed patch to the latest module changes.
Comment #5
blade_ukraine commentedComment #8
benstallings commentedSimple defensive guard. If NestedArray::getValue() returns NULL or empty array (field not found in the form tree), skip it instead of passing it into processDependeeFields() where it would cause errors.
This can happen when a dependency references a field that exists in config but isn't rendered on the current form (e.g. hidden by another module, removed by form alter, or a paragraph field at a delta that doesn't exist yet).
Verdict: Clean, safe, correct. Good to merge.
Comment #10
joelpittet@benstallings The analysis is sound, and thanks for the MR.
I want to make sure we are guarding the right thing though so it would be good to have a regression test to ensure we are really fixing something (and haven't already fixed it in a different way given the commits I have made recently).
So +1 to the fix, a small regression assertion with a red/green tests-only run would nail this shut.
@blade_ukraine Thanks for writing up the patch.