Problem/Motivation
After upgrading from `conditional_fields 4.x-alpha5` to `4.x-alpha6`, an error occurs when handling paragraphs in the `ConditionalFieldsFormHelper` class.
Steps to reproduce
1. Use a paragraph field with conditional fields enabled.
2. Ensure no specific form mode is explicitly selected.
3. Attempt to use the conditional logic that depends on the paragraph field.
4. The following error occurs:
Error : Call to a member function getComponent() on null in Drupal\conditional_fields\ConditionalFieldsFormHelper->getState() (ligne 371 de /var/www/preprod_filiale/releases/20250117120019Z/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).
Proposed resolution
- The issue occurs because `$form_display->getMode()` returns the first unchecked form display mode instead of the default when no specific form mode is selected.
- This causes `$form_display` to be `null`, leading to an error when calling `getComponent()`.
- A patch has been provided to ensure that the correct form display mode is used, preventing null references.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| form-display-error.patch | 760 bytes | marounmt |
Issue fork conditional_fields-3507167
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
avpadernoComment #3
avpadernoComment #4
averagejoe3000I was getting the same error when setting conditionals on fields in paragraphs. I applied the patch and no longer receive the error and conditionals are working as expected.
Comment #5
avpadernoSince patches are no longer supported, a merge request should be provided.