diff --git a/modules/ctools_block/src/Plugin/Block/EntityField.php b/modules/ctools_block/src/Plugin/Block/EntityField.php index 23e8da420bbff833eb6f550fc90257e25852616e..3d7682198a67b85b3967b12656cc5afdf51caf72 100644 --- a/modules/ctools_block/src/Plugin/Block/EntityField.php +++ b/modules/ctools_block/src/Plugin/Block/EntityField.php @@ -137,10 +137,13 @@ class EntityField extends BlockBase implements ContextAwarePluginInterface, Cont /** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */ $entity = $this->getContextValue('entity'); $build = []; - /** @var \Drupal\Core\Field\FieldItemListInterface $field */ - $field = $entity->{$this->fieldName}; - $display_settings = $this->getConfiguration()['formatter']; - $build['field'] = $field->view($display_settings); + + if ($entity->hasField($this->fieldName)) { + /** @var \Drupal\Core\Field\FieldItemListInterface $field */ + $field = $entity->{$this->fieldName}; + $display_settings = $this->getConfiguration()['formatter']; + $build['field'] = $field->view($display_settings); + } // Set the cache data appropriately. $build['#cache']['contexts'] = $this->getCacheContexts();