I think it might be useful to use the form key instead of the cid when looking up previous values of a field. The CID only refers to the specific field on a specific form. I believe the more expected behaviour is to find all instances of that fields values, across all forms.
Consider multiple forms and fields that have the key "favourite_color", the same colors would make sense to auto-complete across all the forms and fields on the site.
This also works in the case of fieldsets that have nested fields with identical keys. Consider a "Person 1" and "Person 2" fieldset each with their own "favourite_color" field.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | webform_autocomplete-auto_complete_by_key-1785470-1.patch | 1.24 KB | sam152 |
Comments
Comment #1
sam152 commentedHere is my patch. Feel free to check it out and roll it into the module if everyone approves. Criticism welcome.
Comment #2
colemanw commentedI think expectations are somewhat subjective.
If you add this feature, I think it should be a configurable option, and disabled by default to keep backward-compatibility with what is.
Comment #3
sam152 commentedFair enough. I will update the status of this issue to be "needs work". If I get around to implementing something I might have a crack at it, for now I will keep it in the pipeline as a feature request.
I am also curious what your use case was for having the `cid` link the fields data together as opposed to the form key and if your use case would be at all effected with this change.
Comment #4
colemanw commentedThe inital use-case did not involve multiple fields, but I can't speak to the other sites now using this module.
Form key isn't necessarily something that people would assume would link fields across multiple forms, but a simple toggle on the component edit form could make that clear (and allow it to be turned off).
Comment #5
kclarkson commentedI have a different use case for the need of form_keys.
I am using the module Webform Bonus Pack where it allows you to send to an email address based on the selection of a component. How it works is that you have to set up a "select list" that has form_keys and then create "mapping" field where it uses form_keys to identify what selection such as: testselection|test@example.com
We have a lot of selections and would like to use this module to create an autocomplete field that sends an email based on the selection.
I have posted a request in their issue queue #1898782: Autocomplete Widget For Large Selections as well but I figured some sort of collaboration would make both of these modules even more awesome.
Thanks again,
K
Comment #6
sam152 commentedI am going to make this as closed. If there is enough interest to turn this into a configuration option a new issue can be opened.