A legacy form #ajax method value causes JavaScript error when selecting branches

Created on 2 January 2025, 7 days ago

Problem/Motivation

Trying to select a branch after entering a project does nothing because the branch select field never updates. This is because the 'replace' method has been changed to 'replaceWith' in Drupal 11.

Steps to reproduce

Select a project in the form, and the branch selector never changes.

Proposed resolution

Update the method to replaceWith:

    $form['settings']['project_id'] = [
      '#required' => TRUE,
      '#type' => 'textfield',
      '#title' => $this->t('Project'),
      '#autocomplete_route_name' => 'config_patch_gitlab_api.autocomplete.projects',
      '#default_value' => $current_project,
      '#ajax' => [
        'event' => 'autocompleteclose',
        'progress' => [
          'type' => 'throbber',
          'message' => $this->t('Loading project branches ...'),
        ],
        'callback' => [$this, 'ajaxRefresh'],
        'wrapper' => $wrapper_id,
        'method' => 'replaceWith',
      ]
    ];

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024