5 users online. Create an account or sign in to join them.Users
Sort order of dynamic options in select boxes
A for , submitted by Nils on 05 February 2010
Announcement
Symphony's issue tracker has been moved to Github.
Issues are displayed here for reference only and cannot be created or edited.
Browse
Closed#222: Sort order of dynamic options in select boxes
I agree with the ordering, it would make more sense for ascending.
I’m not sure how a “natural” sort order can be achieved, since the values are stored as plain text. As such, the sort is alphabetical, hence you see the order 1, 10, 11, 2, 3 ... since the field needs to store both alphabetical and numerical data.
If you need to govern the order of these, you could use a Select Box Link which honours the ordering of the related section (which could be sorted manually with the Order Entries extension).
I’m not sure how a “natural” sort order can be achieved, since the values are stored as plain text.
Shouldn’t it be possible to populate an array with these values before populating the select box and applying natsort() to that array?
Actually it’s quite easy to fix. Replace line 103 of field.select.php
$states = $this->getToggleStates();
with
$states = $this->getToggleStates(); natsort($states);
This will sort the options naturally ascending.
I had no idea the natsort() function existed. Awesome :-)
Looks like this made it into 2.0.7.
This issue is closed.
When dynamically populating select boxes with values of other sections these are sorted in a strange way (see attachment). I would expect two things: