Closed (fixed)
Project:
Reference field option limit
Version:
7.x-1.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jul 2013 at 01:39 UTC
Updated:
30 Oct 2014 at 00:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
donnadion commentedGreat module! But I would call this a bug report.
Using the default select list widget, I choose sort by base property: title to sort by name. Without the option limit, the sort works as expected. With the option limit, the sort does not work, the default (no sort selected) order is displayed.
Thank you!
Comment #2
juto commentedreference_option_limit.module
Comment #3
joachim commentedYou'd need to pick out the ordering that's been set in the field settings. Which depends on the type of field:
- taxonomy ref: term weight
- entityref: field settings
Comment #4
blauerberg commented> - taxonomy ref: term weight
> - entityref: field settings
It seems not working and donnadion's report reproduced in my environment.
Please try this patch.
Comment #5
joachim commentedThanks for the patch! Looks good, just a few tweaks needed:
Could this check the field type is a term ref here? (In case we later add other field types to this module!)
(Also, remember not to coddle the else/elseif.)
Entityref does this:
list($field, $column) = explode(':', $sort_settings['field'], 2);
$query->fieldOrderBy($field, $column, $sort_settings['direction']);
which I think would be easier to read.
Comment #6
blauerberg commentedThanks for review, fixed by #5.
Comment #7
blauerberg commentedoops.. #6 is mistake..
Comment #8
joachim commentedPatch isn't applying to 7.x-1.x I'm afraid!
Comment #9
blauerberg commentedfor 7.x-1.x.
Comment #10
joachim commentedThanks for working on this :)
git commit -m "Issue #2043665 by blauerberg: Fixed filtered entities not sorted." --author="blauerberg "
Comment #12
dariogcode commentedA little note about this. For huge taxonomy terms, weight may have the same value, then term reference will show unsorted. Then sort by name is what we need.
For those interested, I'm using this code in a custom module:
Comment #13
johnpitcairn commented@tilon: I think you mean if there are child taxonomy terms the query result may have duplicate weights.
Here's what I'm using to replace the order by weight if it is the only order in the query: