Empty sortables not possible / Allow two sortables with shared items / Allow items containing form elements
salgar - February 13, 2008 - 10:38
| Project: | jQuery Interface Sortable |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
I have two sortables where the first one is empty per default. The user can drag elements from the second one and drop them on the first one. This works perfect, except if the first one is empty. Then there are warnings and the outer-div is missing on the page.
Suggested fix:
90a91,97 interface_sortable.module
> if (empty($element['#items'])) {
> $order = array();
> $sortables = array(
> '#type' => 'markup',
> '#value' => $sortables['#prefix'] . $sortables['#suffix']
> );
> }
#1
Any chance you could provide a separate patch to interface_sortable_demos.module that demonstrates this?
Thanks,
Marc
#2
I ran into some other problems... I'll make a separate patch to interface_sortable_demos.module and submit it together with an updated patch for interface_sortable.module.
Salgar
#3
I've attached a patch which demonstrates the issue.
There are also issues when the name of a sortable element contains underscores and/or hyphens, but I had no time to investigate this. (I simply changed the names in my module...)
#4
I've attached a new version of the patch, which allows to integrate form elements into the items of a sortable. See the advanced demo for an example. It would be great if you could integrate this stuff.
Salgar
#5
I found out, that using #options as attribute name for the form element is not a good idea. It's used by select elements and drupal may print out a validation error in some cases (see misc/form.inc line 547) when submitting. Best thing is to unset($elements["options"]) at the end of function interface_sortable_process. I've attached a new patch which adresses this issue.
#6
salgar,
Thank you for this patch. I took some time to apply and test it on Firefox and am impressed by the additional functionality. I was wondering if you would have the time to tweak a few things in the patch because I think it would be better coming from you as the author:
1. Document, in the function header, the
$substparameter tointerface_get_sort()2. Document, in the function header, the
$inner_idextra argument that's processed viainterface_sortable_process()-- I'm still a little confused as to why it's needed (this module has always been hard for me to keep my head around)3. Come up with a better name for your super advanced drag-and-drop demo, and put a little bit of descriptive text on the form telling the user that they can drag and drop the items from one region to the other
4. Run it through Coder to make sure it's all up to Drupal standard coding practices (except for the Javascript which has confused Coder in the past)
The first thing I did after applying the patch was to make sure that it didn't break Nodeorder and I was pleased to see that Nodeorder was still working just fine.
- Marc
#7
Any progress on this?