silverstripe-autocomplete
silverstripe-autocomplete copied to clipboard
Add hooks to update returned item data
At the moment you can only return a single database field which prevents you from knowing immediately which ID or DataObject this field belongs to.
Adding the hook would allow more complex structures to be returned. This would leave the dev with the job of blocking the AutoComplete.js and creating their own, but would add more flexibility.
See here regarding returned data: http://jqueryui.com/autocomplete/#custom-data
ps. By 'hook' I mean a callback function to be instance-specific - not a DataExtension which would apply globally.
Example:
$this->setItemFormatCallback(function() { //... blah });
So you would add a hook around https://github.com/tractorcow/silverstripe-autocomplete/blob/3.1/code/AutoCompleteField.php#L255 to customise the ability to extract a value from the dataobject? This can be done pretty easily. :)
I don't see why we couldn't extend it though, since you could add an extension that allows you to assign a callback if needed.
I haven't touched this module for a while and I can see soo many bugs just by looking at the code. =( I'll mark this module to be freshened up.