Problem/Motivation
The new router system breaks the ability to have '/' in an autocomplete_path. As such, it's been suggested that we change the parameters passed to autocomplete as a GET string instead.
This issue was discovered in #1801356: Entity reference autocomplete using routes.
Also, is being discussed in a more general sense in #1827544: [Discussion] Drop automated passing of extra argument: Y/N.
Proposed resolution
Modify Form API #autocomplete_path to pass parameters in a GET string instead.
Remaining tasks
User interface changes
API changes
All modules implementing autocomplete_path callbacks would need to modified to use new syntax.
Comment | File | Size | Author |
---|---|---|---|
#6 | drupal8.autocomplete-query.6.patch | 14.76 KB | effulgentsia |
#6 | interdiff.txt | 8.13 KB | effulgentsia |
#4 | drupal8.autocomplete-query.4.patch | 8.12 KB | sun |
Comments
Comment #1
Crell CreditAttribution: Crell commentedActually... wouldn't they need to be modified to specify a controller, not a path, and then Drupal takes care of forming the appropriate URL?
Comment #2
disasm CreditAttribution: disasm commentedHmm... That's an interesting idea...
I was more envisioning they would manually add a route to the module's YAML file, like /taxonomy/autocomplete that specified the controller, and the #autocomplete_path in the form API would just be:
Then we'd modify the AJAX stuff in autocomplete_path to call taxonomy/autocomplete?string=Foo
I am curious more about your idea though. Maybe we can discuss it during the WSCCI meeting tomorrow?
Comment #3
Crell CreditAttribution: Crell commentedFixing title.
Comment #4
sunKISS?
Didn't update all autocomplete-related tests yet, as I wasn't sure whether this simple solution will be accepted.
Comment #6
effulgentsia CreditAttribution: effulgentsia commentedWorks for me. Here's test fixes and a couple minor code fixes.
Comment #7
effulgentsia CreditAttribution: effulgentsia commentedIMO, the DX change above is a wash, but...
The DX of this got much worse, and will be annoying for every contrib module that implements an autocomplete callback. However, I think we'll be able to improve it as we move controllers to the new route system, because the controller will be able to receive $request (or maybe even $query or $q) as a direct parameter. So please, let's not hold this up on that.
Comment #8
sunThanks!
The Views page callback argument handling looks strange, but those two Views callbacks for users and taxonomy terms shouldn't exist in the first place... ;)
Also, we might want to consider to introduce two base Autocomplete controllers in the future; one for single term autocompletion, and the much more interesting, one for autocompleting a term in a text field supporting multiple tags — it looks like we're duplicating quite some complex code there. Lastly, we have an issue somewhere for introducing a generic entity autocomplete route/callback/handler (but I'm unable to find it right now).
Anyway, for now this simple change seems to be required and a long-overdue clean-up and simplification, so I'd think this is ready to go?
Comment #9
Crell CreditAttribution: Crell commentedComment #10
sunTurns out that ?q= is absolutely great and would make our autocomplete callbacks automatically compatible with #1271622: Seek a better autocomplete replacement for core (jQuery TokenInput / Select2 / Typeahead.js by Twitter) :)
Comment #11
sunActually, I'm not sure what we're waiting for. The patch looks great.
Comment #12
sun#6: drupal8.autocomplete-query.6.patch queued for re-testing.
Comment #13
disasm CreditAttribution: disasm commentedPatch looks good to me. It's even got some good documentation in core/includes/form.inc. If it's green, I don't see why it isn't ready.
Comment #14
Crell CreditAttribution: Crell commentedThis looks good to me, too. Any further Symfony-ification can and should happen in follow-up issues.
Comment #15
Crell CreditAttribution: Crell commentedComment #16
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks.
Comment #18
tstoecklerDoes this need a change notice? I would think yes, but I'm not sure. In writing one for #1817656: Let user_autocomplete also find the anonymous user. I wanted to reference this, but there isn't one.
Comment #19
tstoecklerI wrote some code related to this at the top of http://drupal.org/node/1896862 that could probably be stolen for this (and then removed from there).
Comment #20
xjmComment #21
BerdirCreated http://drupal.org/node/1901518 and updated the change noticed mentioned in #19.
Comment #22
tim.plunkettThat change notice looks good. Seems to actually be more straightforward for module devs.
Comment #23.0
(not verified) CreditAttribution: commentedUpdated issue summary.