On this page
Layout Builder + Auto Generated Content
Sometimes content generated while placing a block is a bit much...

Field Sample Value
Out of the box Layout Builder + uses cores generateSampleItems to get some stuff on the page. Sometimes it produces a bit more than we'd like. Layout Builder + integrates with Field Sample Value to address this.
Install
-
If your site is managed via Composer, use Composer to download the lb_plus module running
composer require drupal/field_sample_value. Otherwise copy/upload thefield_sample_valuemodule to the modules directory of your Drupal installation. -
Enable the 'Field Sample Value' module and desired sub-modules in 'Extend'. (/admin/modules)
-
Navigate Structure > Block Types > Manage fields > Edit. (/admin/structure/block-content/manage/basic/fields/block_content.basic.body)
-
On a text field you should have options to Set a sample value.

The nuclear option
If a field needs a Field Sample Value plugin that hasn't been created yet lets add it! But sometimes Field Sample Value won't get you there either. In that case you can subscribe to the PlaceBlockEvent to tweak anything about the block before it's placed. First, add a service definition.
your.services.yml
services:
place_block.basic:
class: Drupal\your_module\EventSubscriber\TextBlocks
arguments: []
tags:
- { name: event_subscriber }Then add an event subscriber to src/EventSubscriber/PlaceBlockBasic.php.
PlaceBlockBasic.php
<?php
namespace Drupal\your_module\EventSubscriber;
use Drupal\lb_plus\Event\PlaceBlockEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class PlaceBasicBlock implements EventSubscriberInterface {
public function onPrePlaceBlockFormBuild(PlaceBlockEvent $event) {
if ($event->getBlockPluginId() === 'inline_block' && $event->getBundle() === 'basic') {
$block_plugin = $event->getBlockPlugin();
// Change the block plugin configuration.
$configuration = $block_plugin->getConfiguration();
$configuration['label_display'] = 'visible';
$configuration['label_tag'] = 'h2';
$configuration['label'] = $block_plugin->label();
$block_plugin->setConfiguration($configuration);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
// After PlaceBlockFormBuild is called.
PlaceBlockEvent::class => ['onPrePlaceBlockFormBuild'],
];
}
}You can change anything in the block configuration in the event subscriber. If you want to get at the BlockContent within the InlineBlock unserialize the block > tweak it > serialize it back like so:
$block_plugin = $event->getBlockPlugin();
$configuration = $block_plugin->getConfiguration();
$block_content = unserialize($configuration['block_serialized']);
$block_content->set('field_my_select_list', 'option_42');
$configuration['block_serialized'] = serialize($block_content);
$configuration['label_display'] = 'visible';
$configuration['label'] = $block_plugin->label();
$block_plugin->setConfiguration($configuration);Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion
Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.