0

I have an Entity Reference field, whose "type of item to reference" is block.

I have a View that creates a block called staff list but when I edit content that uses that field, I can't get it to present staff list as an option?

Why is this block not selectable? Surely all 'blocks' should be reference-able this way?

Screenshot

1 Answer 1

1

Your field is referencing block config entities. Those exists only for blocks placed in the block layout. If Views creates a block then this is a derivative of a views block plugin and not yet a configured block. You could place the block in block layout, then it shows up in the entity reference select UI. But this is not a good idea. This will cause an error if you remove the configuration and still have references in content.

So better use a different field type. You can place block plugins directly in node fields. See Display custom module block in page content. Or the View directly in a node field, without using a block display. There are a few modules for this:

https://www.drupal.org/project/eva

https://www.drupal.org/project/viewfield

4
  • Thanks. (I'm now recalling this might be why I abandoned D8 years ago!) So I have a paragraph type that wants to offer authors the opportunity to put something in their para. This might be a custom block, a block generated from any number of modules including a view. Blocks used to be a solid reusable concept. But I think you're suggesting I'd need to add one field for every type of block now? This seems to un-do the whole concept of Blocks? Commented Jan 31, 2022 at 15:26
  • Ah. yes, it was. Just found my question from 5 years ago drupal.stackexchange.com/questions/198623/… The block_field project looks promising, though it's a lot more of a headache for authors. Maybe I'll go back to placing the block in a non-rendered region (though I remember there were some other problems with that..). Commented Jan 31, 2022 at 16:11
  • OK, if you want to create a paragraph type which allows the user to place a block generated from any number of modules including Views then your question is a duplicate of the linked question asked recently.
    – 4uk4
    Commented Jan 31, 2022 at 16:12
  • All three modules have their use cases and there are more modules out there. My favorite is the EVA module if you don't want to give the authors a headache.
    – 4uk4
    Commented Jan 31, 2022 at 16:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.