Add Label Help support for the Autocomplete Deluxe widget

Created on 5 July 2025, 5 days ago

Problem/Motivation

Autocomplete Deluxe provides a nicer autocomplete form element, similar to Chosen , but using a different base library, and it supports adding new values. Specifically, it adds a FieldWidget plugin (machine name autocomplete_deluxe) and a FormElement plugin (machine name autocomplete_deluxe).

I've added a Label help message, but it isn't showing up. Using label_help_debug and label_help_debug_dump, I see that label_help is trying to use use case 14, but that doesn't appear to work properly.

Steps to reproduce

  1. Download drupal-11.2.2, autocomplete_deluxe-2.1.2, and label_help-2.0.x-dev
  2. Install Drupal using the standard install profile. Notably this:
    • Sets up a content type with the machine name article
    • Sets up an entity reference field with the machine name field_tags on the article content type
    • Installs core's Claro theme for the administration UI.
  3. Install Autocomplete Deluxe and Label Help
  4. Go to /admin/structure/types/manage/article/form-display and change the widget of the Tags field (i.e.: field_tags) to Autocomplete Deluxe. The default settings are fine. Click the Save button at the bottom.
  5. Go to /admin/structure/types/manage/story/fields/node.article.field_tags and enter a Label help message (or enable label_help_debug and/or label_help_debug_dump in settings.php - amazing feature by the way!)
  6. Go to /node/add/article:
    • Actual behavior: The Label help message is not displayed
    • Expected behavior: The Label help message is displayed

Proposed resolution

Update label_help, and/or autocomplete_deluxe to make it work, and/or document what patches to core we need.

Remaining tasks

  1. Figure out what we need to do
  2. Write a patch
  3. Review and feedback
  4. RTBC and feedback
  5. Commit
  6. Release

User interface changes

Unknown; hopefully none.

API changes

Unknown; hopefully none.

Data model changes

Unknown; hopefully none.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

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

Merge Requests

Comments & Activities

  • Issue created by @mparker17
  • 🇨🇦Canada mparker17 UTC-4

    I was able to get something to work by adding the following to label_help_process_form()...

          elseif (isset($item['widget']['target_id']['#type']) 
            && $item['widget']['target_id']['#type'] === 'autocomplete_deluxe'
          ) {
            $use_case = 15;
            $element = &$form[$key]['widget']['target_id'];
            _label_help_append_title($element, $content, $use_case);
          }
    

    I'll post a merge request shortly for review, but...

    1. I get the sense from the resulting markup that appending to the title is not ideal, from an accessibility standpoint
    2. I'm not certain if I should change the $use_case to a new number

    ... some feedback from the label_help maintainers would be ideal.

    I'm also happy to submit a patch to the autocomplete_deluxe queue if that would make things easier.

  • 🇨🇦Canada mparker17 UTC-4

    MR posted; moving to needs review; feedback welcome!

  • Pipeline finished with Failed
    4 days ago
    Total: 291s
    #539558
  • Pipeline finished with Success
    4 days ago
    Total: 145s
    #539559
  • 🇪🇨Ecuador jwilson3

    Maintainer here. Thank you for the excellently written issue complete with MR!

    I get the sense from the resulting markup that _label_help_append_title() is not ideal from an accessibility standpoint

    You're probably right here. _label_help_append_title() is kind of the "worst case" scenario when nothing else works.

    So what I recommend you do is to replace that with the other options to see if any of the other options work better and put the label help in the correct place, visually, on the form element.

    _label_help_prepend_field_prefix($element, $content, $use_case);
    _label_help_prepend_description($element, $content, $use_case);
    _label_help_append_label_suffix($element, $content, $use_case);

    If any of these work better than append_title, pls update to the MR. If not, leave a comment to that effect.

    Thank you!

  • 🇪🇨Ecuador jwilson3

    I'm not certain if I should change the $use_case to a new number

    The use_case needs to be incremented to the lowest unused number. (Currently that would be 18).

  • 🇨🇦Canada mparker17 UTC-4

    @jwilson3, thanks for the quick response and help!

    I will update the patch to set $use_case = 18 in the new code.

    I tried the other other placement options to see if any worked better, and, unfortunately, they did not (details below).

    So we will have to stick with _label_help_append_title() for now. (maybe I can submit a patch to autocomplete_deluxe but my initial attempts at a patch haven't been successful).

    To be more specific...

    _label_help_prepend_field_prefix($element, $content, $use_case);

    The label help text wasn't output at all with prepend_field_prefix

    _label_help_prepend_description($element, $content, $use_case);

    The label help text appeared below/after the input box and above/before the field description, but this isn't ideal, because I need the help text above/before the input box where users will notice it. Put another way, I could get an effect similar to prepend_description by adding a newline to the description itself, so this doesn't really add anything.

    _label_help_append_label_suffix($element, $content, $use_case);

    The label help text wasn't output at all with append_label_suffix

  • 🇨🇦Canada mparker17 UTC-4

    I've pushed a commit with an updated use_case; so I'm moving this back to Needs Review. Reviews welcome! Thanks again!

  • Pipeline finished with Success
    1 day ago
    #541428
Production build 0.71.5 2024