I'm using multiselect with content_taxonomy to choose options in a vocabulary with about 200 terms, and required this widget to preserve the order of options for usability reasons. I implemented this by setting an ID attribute on each option, and sorting on that in javascript. This unfortunately required a hack involving preg_replace() in theme_multiselect_select() because the Drupal FAPI doesn't allow setting arbitrary attributes for select options.

While I was at it, I implemented another hack: I emulated optgroup-style option groups using the disabled attribute, CSS, and another regular expression which checks for ' - ' at the beginning of an option's value string. This is obviously not the right way to do this but it's working for me so I left the code there (commented out) as a starting point for anyone else who has time to write it properly, or wants to use it as-is.

CommentFileSizeAuthor
multiselect_order.patch7.25 KBmvc

Comments

attheshow’s picture

Status: Needs review » Closed (won't fix)

I'm glad this worked for you, but it doesn't look like this would be universally useful, so I'll mark it as "won't fix" for now.

grasmash’s picture

I'm also finding this to be an issue. I think it makes sense to develop this as a feature. I'll attempt to patch this and see if I can improve upon it.

FreeFox’s picture

Status: Closed (won't fix) » Active

Because I wanted to ask the same question there are already 3 of us ;) so I took the freedom to put it back to active, no offense.

However, I use the 7.x branch so please include this request for all versions if possible.

Thanks in advance

grasmash’s picture

I applied this patch and it seemed to work at first. But I've since discovered that this patch somehow prevents the 'selected terms' list from correctly populating with currently assigned terms on the node edit page. I'll be looking further into it...

mparker17’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

multiselect-6.x-1.5 is no longer supported, because Drupal 6 is no longer supported; and multiselect-7.x-1.x is no longer supported, because Drupal 7 is no longer supported.

Can you confirm if this is still needed in multiselect-2.0.0-beta4?

I'm going to mark this issue as "Postponed (maintainer needs more info)"... but when you answer, please change it back to "Active". If there is no reply in ~6 months, then I will mark this issue as "Closed (outdated)". Thank you in advance for your understanding and patience as I try to keep this module's issue queue clear.