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
API changes
Data model changes
Release notes snippet