Add #autocomplete_callback option for form elements

Created on 19 August 2015, almost 10 years ago
Updated 27 May 2025, 4 days ago

Currently the textfield form element supports the #autocomplete_route_name attribute for autocompletion. This mostly means that the handler for this request resides in the element class itself and a route has to be manually defined for it.

I think that in most situations the developer would just like to define a specific callback and Drupal should take care of invoking it on a system route, just like it does for ajax forms.

What I imagine is that the #autocomplete_callback would be a callable that would return an array of results. Drupal would, on system path, invoke this callable, pass the arguments and wrap the resulting array into JsonResponse automatically.

This would mean the developer would not have to use JsonResponse and define any routes so no CC would be needed in order for changes to apply(ie. changed route or route controller).

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

forms system

Created by

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024