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.

Comments

sam152’s picture

Status: Needs review » Patch (to be ported)
StatusFileSize
new1.24 KB

Here is my patch. Feel free to check it out and roll it into the module if everyone approves. Criticism welcome.

colemanw’s picture

I 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.

sam152’s picture

Status: Patch (to be ported) » Needs work

Fair 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.

colemanw’s picture

The 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).

kclarkson’s picture

I 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

sam152’s picture

Status: Needs work » Closed (won't fix)

I 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.