Problem/Motivation
My entityreference field shows users with particular roles; they're ordered by UID by default. I sort them by "User: Name" for better UX. It stops working after updating from 7.x-1.5 to 7.x-1.8, defaulting back to the UID default sort.
Steps to reproduce
- Create an entityreference view of users; filter only users with a particular role; do not add any sort criteria yet.
- Add a new Entity Reference field with Select List widget to a content type. Under Entity Selection, reference the view above.
- Create a new node of the above content type, notice the Entity Reference field users are sorted by UID as expected.
- Edit the source entityreference view, adding Sort Criteria > User: Name (sort ascending). You should see the user names presented in alphabetical order in the preview below. Save the view.
- Flush caches to be safe
- Create a new node of the above content type, notice the Entity Reference field user entities are still sorted by UID, which does not match the entityreference view.
Comments
Comment #2
joseph.olstadHello, thanks for reporting, please test the available patch and report the version of PHP you're using and report success results.
The patch is here:
#3349989-6: Field reference do not use order (asc,desc) that done in views reference
Comment #3
joseph.olstadI would like some more reviews of the fix before putting it in. Particularly testing results with PHP 8.2
Comment #4
jvogt commentedThis is still an issue for me in 7.x-1.9 when the field is referencing User entities. Tested on both php 7.4 and 8.1. It ignores both "A field attached to this entity" and "A property of the base table of this entity."
Comment #5
joseph.olstad@jvogt what does this say?
drush pml | grep entityreference -iComment #6
jvogt commentedWell, I downgraded back to 7.x-1.6, but after running
drush dl entityreference, the output ofdrush pml | grep entityreference -iis: