Article
Posted on 2nd October 2024
Takes about 4 mins to read

Drupal's form API has been brilliant for many years. Still, recently I found myself wondering why I needed to build a configuration form if I already had a schema for my config. Defining a schema facilitates API-first validation (including some pretty smart constraints), specific typing (e.g. actual booleans or integers instead of '0' or '1' strings), and even translation in Drupal. That last part got me thinking; if Drupal automatically provides translation forms for typed...

Article
Posted on 29th June 2022
Takes about 2 mins to read

Here's a super simple tip to help you work with services for Drupal in PhpStorm ( our favourite IDE). First, ensure you have enabled the Drupal Symfony Bridge and Symfony Support plugins; they're brilliant for auto-complete suggestions, and navigating around services, controllers, annotations and twig templates! I find it so helpful to be able to cmd+click (or ctrl+click) on a service name, whether in a YAML definition, or PHP code, and jump straight to the service class. But I'd noticed that PhpStorm often didn't recognise the method used after my code referred to a service like this: \Drupal::service('my_service') ->something($id);

Published in: #Drupal Planet #Custom code #Symfony
Article
Posted on 29th November 2016
Takes about 8 mins to read

In a recent Drupal 8 project, one of the site's vocabularies had several thousand terms in it (representing airports), which caused its admin listing page to run out of memory before it could render. I wanted to solve this without affecting any other vocabularies on the site, and improve the listing itself along the way to be more useful, with filters to make searching it much easier. The original listing is not a view, and loads much more than it needs to. Here's the customised page for airports that I wanted to head towards: