- Issue created by @gidel
- Merge request !74Issue 3515565: Fix fatal error on $values array test. → (Open) created by Unnamed author
If I add a condition on a field, controlled by a media field with the "empty" condition, the block creation failed with a fatal error.
"Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array in Drupal\conditional_fields\ConditionalFieldsFormHelper::evaluateDependency()"
- Use conditional_fields (4.0.0-alpha6), media and media_library.
- Create a block content with a media field, and another field (which will be the target field)
- Add a condition for the block (admin/structure/conditional_fields/block_content): set a target field, and the media field as "controlled by". Set the condition to "Empty" (for example: if media field is empty, hide the target field).
- Add a content block (/block/add), and fill the fields (the media field can be fiiled or let empty).
- Click on "save" button.
- A fatal error occurs with the message : Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array in Drupal\conditional_fields\ConditionalFieldsFormHelper::evaluateDependency() (line 936 of modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).
Add a condition (like already added for the !empty condition in the evaluateDependency() method) to check if the variable $values is an array before trying to assign an array key of the variable ($values[0]['value'])
Active
4.0
Code