ajax

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, 6 March, 2012
Today I needed to create an ajax powered form using Drupal 7, the caveat being that I needed one user action to perform multiple ajax actions to different sections of the form. To begin, my form element with the ajax looks like this:

  $form['company']['company_branches'] = array(
    '#type' => 'select',
    '#title' => t(