Presently, the autocomplete callback returns results by assuming the field should be a multiple value reference. I believe it also looks for settings in the field settings array to determine valid product types. That should be altered so the same autocomplete code can work fine on a non-field form element.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | product_autocomplete_single-745332-4.patch | 3.48 KB | vasike |
Comments
Comment #1
pcambraComment #2
pcambraComment #3
pcambraI'm not sure of how to face this as the autocomplete function is highly dependent on the field and instance info:
The product reference field calls the autocomplete path this way:
'#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $instance['entity_type'] . '/' . $field['field_name'] . '/' . $instance['bundle'],Then, the autocomplete gets the parameters, being the string the last one:
function commerce_product_autocomplete($entity_type, $field_name, $bundle, $string = '') {And finally the products are returned by the match product function that uses both the field and the instance.
commerce_product_match_products($field, $instance, $tag_last, $match, array(), 10);What should be done here?, a base autocomplete function and then depending on the information provided by the caller (field, entity_type, bundle...) fetch the products in one way or another?
Comment #4
vasikehere is a patch inspired by Entity Reference autocomplete.
Comment #5
rszrama commentedWe cannot prepend an argument to this function. It would break any other module depending on the current signature.