Required Block inside Blocks Field

Hey everyone,

I have a question regarding the Blocks Field. I have a blocks field that can contain a bunch of different blocks like image galleries, texts and so on. So far nothing special. But I do have one special block. That block should be present in every instance of the Blocks Field exactly once.

I wonder if there is some blueprint magic to configure the block builder in such a way or if I would have to do that myself using hooks. If it’s the latter would this strategy work? Sorry for the ugly pseudocode

page.create:after hook
	if (page contains block-field):
		specialblock = new Block('specialblock-content')

page.update:before hook
	if (page contains block-field)
		if(page->blockfield->toBlocks()->filterBy("type", "specialblock")->count() !== 1)
			throw new Exception('block field needs to contain one specialblock')

Has anybody dealt with a similar situation and has a good solution?
Thanks for your help!

Where should this block appear (beginning, end)? Does it have to be visible in the Panel or just when rendering the page?

The blocks position isn’t fixed. In most cases it will be at position 2, but there might be exceptions. It definitely has to be visible in the panel.

Then using the hooks is your only option, I think. Although you will only need it at update, because at page creation you can set the special block as default: