nerdfisch: DevBits

Kleine, aber feine Code-Snippets, nützliche Tweaks und elegante Lösungsansätze aus dem Entwickler-Alltag

23.04.2026 | Lothar Ferreira Neumann

Add custom text to gin_login with Form Decorator

We will use the form_decorator module to alter the output of the gin_login module to look something like this:
 

An example what the result looks like when using gin_login_text.

 

This DevBit provides a step-by-step tutorial how to get there. 

13.04.2026 | Pascal Crott

Restore AJAX functionality when using Slick Slider and Layout Builder

Uses new Drupal "once" Library without using JQuery (see: https://www.drupal.org/node/3158256).

content-carousel.js
          slick.on('breakpoint', function (e, _) {
            if (settings.isLayoutBuilder) {
              once.remove('ajax', '.use-ajax', _.$slideTrack[0]);
              Drupal.ajax.bindAjaxLinks(_.$slideTrack[0]);
            }
          });
13.04.2026 | Marc Hitscherich

Chrome: Bypass NET::ERR_CERT_INVALID

Issue:

If a website has an invalid SSL certificate there might be no way to bypass the validation warning and access the actual website. Especially in Chrome sometimes the button beneath the error message to explicitly bypass the certificate warning is not available.

Solution:

To access a website despite an invalid certificate in Chrome, place the cursor somewhere on the browser window and try typing »thisisunsafe«.

02.04.2026 | Michael Ebert

Set a custom theme to be used by Symfony Mailer

symfony_mailer.mailer_policy._.yml
configuration:
  email_theme:
    theme: my_custom_theme

02.04.2026 | Lothar Ferreira Neumann

Updating user roles using a module update hook

switch_roles.install
<?php

use Drupal\user\RoleInterface;

/**
 * Remove the old roles and replace them with the new ones.
 */
function MY_MODULE_update_9041(): void {
  $em = \Drupal::entityTypeManager();
  $user_storage = $em->getStorage('user');

  // Ensure the new role exists. If not, create it first.
  $role_storage = $em->getStorage('user_role');
  if ($role_storage->load('new_role') === NULL) {
    /** @var \Drupal\user\RoleInterface $role */
    $role = $role_storage->create([
      'id' => 'new_role',
      'label' => 'New role',
    ]);
    $role->save();
  }

  $uids = \Drupal::entityQuery('user')
    ->accessCheck(FALSE)
    ->execute();

  if (empty($uids)) {
    return;
  }

  /** @var \Drupal\user\UserInterface[] $users */
  $users = $user_storage->loadMultiple($uids);

  foreach ($users as $user) {
    if ($user->hasRole('old_role')) {
      $user->addRole('new_role');
      $user->removeRole('old_role');
    }

    $user->save();
  }
}