Hi,
Thanks for including formatters for Link and EntityReference :)
They work fine so far. However, I get the following warning when an EntityReference field is empty and not displayed at all:
Notice: Undefined variable: target_entities in textformatter_contrib_entityreference_field_create_list() (line 58 of .../textformatter/textformatter_contrib/textformatter_contrib.module).
Warning: Invalid argument supplied for foreach() in textformatter_contrib_entityreference_field_create_list() (line 58 of .../textformatter/textformatter_contrib/textformatter_contrib.module).
It seems that the formatter is called even though it shouldn't be displaying anything and the code doesn't handle this correctly. It's independent of which list type I choose and whether the items are linked to the entities or not.
In fact, adding a
if (isset($target_entities)) { ... }
block around the
foreach ($target_entities as $id => $entity) { ... }
block seems to fix it for me.
Thanks!
Comments
Comment #1
damiankloip commentedYeah, that's a good point, That's a pretty easy fix and will do what we need. Will look @ now. Thanks lukasho!
Comment #2
damiankloip commentedActually, we can just set the $target_entities variable as an array at the start of the function and we should be good.
Comment #3
damiankloip commentedOK, fix committed, can you please confirm?
Comment #4
damiankloip commentedThis is working ok now, please re open if not!
Comment #6
soulston commentedHi, I am getting this error when using 7.12 version:
This is happening on a page that uses the formatters but where there is no content in those fields. I am also using display suite so I'm not certain if this is also a factor?
Comment #7
damiankloip commentedThis is fixed in the dev branch.