silverstripe-autocomplete icon indicating copy to clipboard operation
silverstripe-autocomplete copied to clipboard

Add hooks to update returned item data

Open micmania1 opened this issue 10 years ago • 2 comments

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

micmania1 avatar Mar 20 '14 11:03 micmania1

ps. By 'hook' I mean a callback function to be instance-specific - not a DataExtension which would apply globally.

Example:

$this->setItemFormatCallback(function() { //... blah });

micmania1 avatar Mar 20 '14 11:03 micmania1

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.

tractorcow avatar Mar 20 '14 20:03 tractorcow