I'm in Drupal 8 trying to load a Views Exposed Filter block based on its ID, similarly to how I would load a content block.
$bid = 'exposedformview_nameview_display_name'; // Found on mysite.test/admin/structure/block/manage/exposedformview_nameview_display_name/
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityManager()
->getViewBuilder('block_content')
->view($block);
return $render;
Nothing ends up printing out, and in the error log I see this message:
Recoverable fatal error: Argument 1 passed to Drupal\block_content\BlockContentViewBuilder::view() must implement interface Drupal\Core\Entity\EntityInterface, null given
Sure enough, when I debug($block)
, it shows NULL.
I know this works for other blocks created in the content placement area, not sure why it wouldn't also work for views exposed filter blocks. They are both available for placement in the manage blocks page.
EDIT: It seems as though it will not be possible to load the block like this. This method depends on revisions being available for blocks. There is no revision for a views exposed filter block so there must be another way to accomplish this. Perhaps by loading the form directly.