Similar feature request to one from the Block Reference module: #659584: Select widget fix for re-ordering blocks

I need to be able to sort the selected values from a select list (in my case it was for a Node Reference). With the "multiple values" select list, you have to hold ctrl or shift to select multiple values, and you CANNOT re-order them.

So I borrowed some code from the autocomplete widget to create a drag and drop sortable widget for select lists. It doesn't replace the Select list widget, it simply adds an additional widget to the drop-down.

Is there already a module which provides this? I searched and didn't find one. Regardless, it seems like a good idea to add this to CCK or Core in D7.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pifantastic’s picture

Tested this patch with cck3 and it works well! One of the patch chunks fails so I updated the patch for cck3.

Thanks @jmonkfish this is exactly what we were looking for.

jeff.k’s picture

This is awesome. I have been looking for something like this for a while.

It would be great to have this in the core cck for all select lists options.

brian_c’s picture

Thanks for the patch, very useful.

There seems to be an issue with HTML entities though. Specifically, it is replacing ampersands with & when it shouldn't be, like in the middle of an entity reference.

For instance, it is transforming ' (which should render as an apostrophe) into ' (which renders as ').

So "Bob's Foobar" renders as "Bob's Foobar".

I solved this by changing theme_nodereference_select_sortable() to:

function theme_nodereference_select_sortable($element) {
  return str_replace( '&#', '&#', $element['#children'] );
}

Seems like a workaround though, ideally would be better to track down where the original replacement is occurring and prevent it.

pifantastic’s picture

Just out of curiosity, has anyone used this patch on a CCK field inside a multigroup? At first glance it does not appear to work. I haven't had a chance to dive into the code and look for a fix.

firebus’s picture

subscribing! it's unfortunate that multiple node references don't allow ordering the way that most multiple fields do.

are the maintainers interested in providing this feature? i assume we'd need a patch for 7 and 6.x-3.x before it can be committed to 6.x-2.x?

rupl’s picture

Status: Active » Needs review
FileSize
5.22 KB

Re-rolling the patch from pifantastic in #1 against current 6.x-3.x-dev

One small change, because the auto-complete results contained some HTML. I added an optional flag to nodereference_allowed_values() to allow output of 'title' instead of hardcoded 'rendered' option, which is now default.

rupl’s picture

Version: 6.x-2.6 » 6.x-3.x-dev

Forgot to update version!

ramotowski’s picture

After click "Add another item" all values in select lists appears empty.

bingorabbit’s picture

Any idea about a Drupal 7 Port?!