backend
Option 1 (recommended): custom entity reference selection handler. Further options down below.
ActiveUserSelection.php
<?php
namespace Drupal\my_module\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\UserSelction;
use Drupal\Core\StringTranslation\TranslatableMarkup;
#[EntityReferenceSelection(
id: "default:active_user",
label: new TranslatableMarkup("User selection (only active users)"),
entity_types: ["user"],
group: "default",
weight: 1
)]
class ActiveUserSelection extends UserSelection {
/**
* {@inheritdoc}
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
$query->condition('status', 1);
return $query;
}
}After implementing that plugin, you need to activate it on the entity form display for the field you want it.
08.10.2026 | Michael Ebert
Filter user entity reference field options to active users only
You can add headlines to a webform using the code below. To get to the source section, navigate to the form you want to alter, click on build and then on the source tab like in the screenshot.
This is just a short example on how to add a headline.
webform_headline.yml
personal_data:
'#type': html_tag
'#tag': h3
'#value': 'Personal data'It will look something like this:
13.11.2025 | Lothar Ferreira Neumann
How to place HTML elements into webforms via the Source tab
If this does not work...
broken_fapi_autocomplete.php
$form['nodes'] = [
'#title' => $this->t('Select articles'),
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#tags' => TRUE,
'#selection_handler' => 'default',
'#selection_settings' => ['target_bundles' => ['article']],
'#default_value' => $default_nodes,
];...try adding an increased maxlength value:
fixed_fapi_autocomplete.php
$form['nodes'] = [
'#title' => $this->t('Select articles'),
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#maxlength' => 1024,
'#tags' => TRUE,
'#selection_handler' => 'default',
'#selection_settings' => ['target_bundles' => ['article']],
'#default_value' => $default_nodes,
];
13.08.2026 | Pascal Crott
Can't save Form API autocomplete when referencing too many elements
my_module.routing.yml
my_module.edit:
options:
# Enable the admin theme for this route.
_admin_route: TRUE
05.10.2026 | Michael Ebert
Enable the admin theme for your custom route
RouteSubscriber.php
<?php
namespace Drupal\scp_base\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Make sure profile pages are not admin pages, in order to load the right
// translation.
if ($route = $collection->get('profile.user_page.single')) {
$route->setOption('_admin_route', FALSE);
}
}
}
13.11.2025 | Pascal Crott
Prevent the user profile from being displayed in backend theme using RouteSubscriber
Issue:
You want to use the Gin edit form for all content entities, including custom entities.
Solution:
The Gin Everywhere module was developed to solve this specific issue.
26.02.2026 | Pascal Crott