nerdfisch: DevBits

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

13.11.2025 | Lothar Ferreira Neumann

How to place HTML elements into webforms via the Source tab

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.

Screenshot of the menu to add code to webform

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:

Headline within a webform
yml
html
manipulating forms
backend
13.11.2025 | Lothar Ferreira Neumann

Set the homepage for anonymous users to login page

Access front page setting here: /admin/config/system/site-information

Set home page to user login
system.site.yml
page:
  front: /user/login
drupal
Sitebuilding
login
13.11.2025 | Lothar Ferreira Neumann

Use ternary statements in Twig

ternary-example.html.twig
{# Checks if a URL exists and passes it to the component. Otherwise, sets it to false. Works with primitive data types. #}
{% set link = url ? { url: url } : false %}

{# Checks if the media object is not empty and passes it to the component. Otherwise, sets it to false. Suitable for complex data types like objects. #}
{% set media = media is not empty ? { media: media } : false %}
html
twig
twig
ternary operators
13.11.2025 | Henjo Völker

Jira JQL Filter: Issues with a date field value in the next upcoming month

filter_jira_issues_inside_upcoming_month.jql
AND "[yourDateField]" >= startOfMonth("+1") AND "[yourDateField]" <= endOfMonth("+1")
JQL
Jira
project management
issues
13.11.2025 | Holger Weischenberg

Check whether there is only one child item using CSS

.breadcrumb.scss
    .breadcrumb--item:only-child {
      svg {
        display: none;
      }
    }
    
breadcrumb
css
copy-paste