By Phil Frilling, 7 April, 2021

Recently, I was building a custom Drupal form that used dependency injection and included an ajax submit handler. While testing the form, on the initial page load, the form submitted just fine using ajax. However, when the user used another ajax handler on the same form, all of the injected services were set to `NULL`.

It turns out that I had my services set to be

By Phil Frilling, 21 November, 2018

In a recent project, we were using an external service that pulls our site into their system and injects their content into our project. The issue we ran into was that the third party was overwriting all links in the template we provided with their HTTP host, causing the menu system from our Drupal site to break. To get around this we needed to generate absolute links for all of our menus.

In order to accomplish this we used template_preprocess() to dynamically provide our site's hostname as a variable:

By Phil Frilling, 9 November, 2018

I arrived this morning to a Postfix mail queue with more than 14,000 messages queued up. After inspecting the queue with

postqueue -p

I found that most of the messages were from a single spammer to a specific user. In order to clear the queue of these spam messages, I found the following bash script to delete all messages from a single sender to a single user:

By Phil Frilling, 19 September, 2018
Drupal 8 custom validation of multiple entity fields In a recent Drupal 8.6 project, I was using the media entity type to add custom fields to pdf documents. These pdf files contain two fields: a select list and a text field. When a specific select option is chosen, the text field becomes required. I could have used a form alter function to add my custom validation for these fields, but this would limit my validation to just one form.
By Phil Frilling, 5 September, 2018
I was tasked with breaking the user registration form of a Drupal 8 installation into a multi-step form. This was necessary because depending on what a user selected in step one, they were shown different form fields in step two. To begin, I added all of the fields I needed to the user profile using the GUI. (/admin/config/people/accounts/fields). Then, I added the fields I needed to the manage form display/register tab (/admin/config/people/accounts/form-display/register). This gave me a working, one page registration form.