1

I need to remove an entity from the display.

With hook_entity_view_alter(), I am trying to change the $build array.

$build['disable'] = true;
$build['#entity']['disable'] = true;
$build['#entity'] = "";
$build['#entity']['#access'] = FALSE; 

This is all wrong.

$build['entity'] is of type Drupal\eck\Entity\EckEntity and not a renderarray.

What is the correct way to hide an entity from the display?

6
  • $build['entity']['#access'] = FALSE;?
    – Clive
    Commented Oct 5, 2017 at 13:47
  • $build['entity'] is of type Drupal\eck\Entity\EckEntity and no renderarray. $build['#access'] = FALSE; also does not work.
    – mogio
    Commented Oct 5, 2017 at 13:52
  • Which entity is displayed doesn't change the code to use. @Clive code is correct. If you have any reason for not using it, please update your question to explain that.
    – avpaderno
    Commented Oct 5, 2017 at 13:55
  • 1
    #access to false.
    – Kevin
    Commented Oct 5, 2017 at 14:01
  • @Clive I updated the question. ['#entity'] is an object and not a render array. Thanks
    – mogio
    Commented Oct 5, 2017 at 14:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.