Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When Entity Reference is interacting with different modules, can produce the following error:
Notice : Undefined variable: element in entityreference_field_formatter_settings_form() (line 1141 in /sites/all/modules/entityreference/entityreference.module).
I found it is given because $element is display type is none of the expected ones. I have added a simple check to avoid returning $element if not set.
Comment | File | Size | Author |
---|---|---|---|
#8 | entityreference-2495405-2.patch | 526 bytes | jenlampton |
#6 | entityreference-undefined_variable-2495405-6.patch | 566 bytes | jenlampton |
#2 | entityreference-2495405-2.patch | 526 bytes | geoffreyr |
entityreference_2314339.patch | 243 bytes | dtamajon | |
Comments
Comment #1
geoffreyr CreditAttribution: geoffreyr commentedThis seems to be triggered when selecting Entity ID as the display type. Currently noticing this while I try and Formatter Field working with Paragraphs - there's no initialisation for
$element
taking place in this function.Comment #2
geoffreyr CreditAttribution: geoffreyr commentedHere's a really tiny patch that should address the issue.
Comment #3
DamienMcKennaComment #4
Devin Carlson CreditAttribution: Devin Carlson commentedThis is very easy to run into while using the Entity Embed module.
The one-line patch in #2 applies cleanly to Entity Reference 7.x-1.x and ensures that
$element
is always defined. This is the same approach taken by the example implementation ofhook_field_formatter_settings_form()
infield_ui.api.php
.Comment #6
jenlamptonPatch in #2 didn't apply to 7.x-1.x-dev for me. Rerolled.
Comment #8
jenlamptonUploading previous patch to see if that passes tests, maybe my local branch is borked?
Comment #9
jenlamptonyeah, looks like it. setting back to RTBC.
Comment #10
Devin Carlson CreditAttribution: Devin Carlson commentedRe-tested #2 and committed it to Entity Reference 7.x-1.x.