Closed olafgrabienski closed 3 years ago
I have added a PR that should allow a view to be used to filter autocomplete options.
Thanks for the PR, @hosef! I've installed the branch on a test site, built a View with a Reference display. Then, in the settings of my Reference field, I was able to select the view as filter. And: the filter was respected when I tried to reference content. Great!
What is not covered so far, is the display of the Views fields in the autocomplete. Were you planning to add it as well? Not sure if I mentioned the autocomplete display aspect of the request clear enough in the issue description:
Based on this feature, it's possible to adjust the view to show the editor a custom list of content which can be referenced, e.g. including additional fields like the post date or a thumbnail (...) It's very useful when the standard list of alphabetically sorted titles doesn't fit the needs, for instance when you have a lot of content with same or similar titles.
What do you think about it?
PS: Testing the PR, I got the following message during Views configuration:
Display "Reference" needs a selected search fields to work properly. See the settings for the Entity Reference list format.
There's a typo ("search fields"), and it shouldn't be "Entity Reference list" but "Reference list".
@hosef - I'm posting a screenshot of a Entity Reference autocomplete for demonstration purposes. The autocomplete displays the Views fields Date - Author - Title
. In this case, it was important to (sort the results by date and) show the dates and the authors, because there are many results with the same title ("ohne Titel", which actually means "no title" but that's another story).
The PR looks great as a first step! I'd also love the views configuration to affect the autocomplete results as @olafgrabienski described, but I've merged the PR but we can add more features to what's there already.
@jenlampton Thanks for merging the PR! Would you prefer a new issue regarding display of the autocomplete results, or should we continue here?
Whatever works for you and @hosrf is fine :)
On Wed, Mar 17, 2021, 1:58 AM Olaf Grabienski @.***> wrote:
@jenlampton https://github.com/jenlampton Thanks for merging the PR! Would you prefer a new issue regarding display of the autocomplete results, or should we continue here?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/backdrop-contrib/reference/issues/23#issuecomment-800913410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBER67Z5O4K54XBUEESN3TEBVKZANCNFSM4DTBQYDQ .
@hosef What do you prefer regarding the display of autocomplete results: a separate issue or continue here?
I can continue working on it here. I'll just make a new PR when I get it working.
@jenlampton I created a new PR that changes the output from the autocomplete to use the views output instead of custom text formatted from the entity label.
Thanks! This change will affect https://github.com/backdrop-contrib/reference/issues/22 (but the PR there needs work anyway).
With the other referencing module, References, the list of 'referencable' content on the node form can be provided by a view using the "References" display type. Based on this feature, it's possible to adjust the view to show the editor a custom list of content which can be referenced, e.g. including additional fields like the post date or a thumbnail, or with custom filters, sort criterias and many more.
I've used this feature (actually with Entity Reference in Drupal) a couple of times. It's very useful when the standard list of alphabetically sorted titles doesn't fit the needs, for instance when you have a lot of content with same or similar titles. Another great advantage is the possibility to make list of selectable content more user friendly.
I'd love to use the feature, and as it is part of References which we are planning to replace with Reference in core, I hope that we can get it in.