I have a custom content entity that renders fine in its page view and form. I'm now trying to view one of its fields in a table using an EntityListBuilder, but the following code throws an error message:
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity->id();
$row['email'] = $entity->email->view();
return $row + parent::buildRow($entity);
}
Results in:
Fatal error: Call to undefined method Drupal\my_module\Entity\MyEntity::render() in /.../core/lib/Drupal/Core/Template/Attribute.php on line 294
Apparently the view builder expects a render() method, which I do not have, and which I do not want to implement, since the entity renders fine otherwise...
Also tried EntityViewBuilder::viewField() with no success.
Even when I'm viewing a node instead of my custom entity, I get the same message.