Support for AJAX events

Created on 24 October 2022, about 2 years ago
Updated 17 September 2024, 3 months ago

Problem/Motivation

I'm trying to add some Drupal Form AJAX logic to an autocomplete_deluxe form field. When the autocomplete field's input changes I would like to call an AJAX callback and return additional information to display in the form.

I've tried adding #ajax to my form element as I normally would do for a entity_autocomplete field but just can't seem to make it work. I don't see any console errors or requests of any kind going back to Drupal. It may very well be that this just isn't supported, but I don't see and documentation/indication of that. I did my best to search the issue queue for 2.x-dev as well but did not see the same issue reported.

Steps to reproduce

Here is a sample of what I am trying:

      $form['location'] = [
        '#type' => 'autocomplete_deluxe',
        '#title' => $this->t('Location'),
        '#autocomplete_deluxe_path' => $url, // $url is built above and works fine, I can select values in the UI.
        '#target_type' => 'asset',
        '#multiple' => TRUE,
        '#required' => TRUE,
        '#weight' => -100,
        '#ajax' => [
          'callback' => [$this, 'assetCallback'],
          'wrapper' => 'asset-wrapper',
          //'event' => 'autocompleteclose',
          'event' => 'change',
        ],
      ];

Proposed resolution

Remaining tasks

  • ✅ File an issue
  • ➖ Addition/Change/Update/Fix
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
Feature request
Status

Active

Version

2.0

Component

User interface

Created by

🇺🇸United States paul121 Spokane, WA

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024