Opened 13 years ago

Last modified 11 years ago

#16730 new New feature

serializing forms which use FilteredSelectMultiple

Reported by: alan.kesselmann@… Owned by:
Component: contrib.admin Version: 1.3
Severity: Normal Keywords: nlsprint14
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Hello!

This is minor but annoying problem.

I use django.contrib.admin.widgets.FilteredSelectMultiple on publicly visible page and post forms contents with ajax - gathering data with form.serialize(). When doing so i noticed that info from the select widget was not sent to server. I followed problem to django/contrib/admin/media/js/SelectBox.js and to SelectBox objects render method. The problem why jQuery.serialize() does not serialize selects contents is simply because those options arent selected after moving from one select to another. And they arent selected because SelectBox.render() is called after each moving - and after it none of the options have selected attribute.

Like i said - it is not big problem and it has workaround - you have to select the options in 2nd select if you want form.serialize() to pick up its contents. But when selects contents are many, then this is not easy. It would be much easyer if they remained selected after beeing moved from one select to another.

Alan

Change History (11)

comment:1 by anonymous, 13 years ago

UI/UX: set

comment:2 by Julien Phalip, 13 years ago

Triage Stage: UnreviewedDesign decision needed

I see how this can be annoying in some situations like yours, however the case can also be made that keeping the items selected could be confusing for the user. What if, for example, some items in the destination list were already selected before the move? Would the moved ones be appended to the selection or would the prior selection in the destination list be cleared before re-selecting only the freshly moved ones?

comment:3 by Julien Phalip, 13 years ago

Component: Formscontrib.admin

comment:4 by alan.kesselmann@…, 13 years ago

The selected items would be appended to previous selection in destination list.

Why im so fond of this widget is that i had to create one such widget for myself for one php project. After prototyping our decision was to keep items in destination list selected all the time. Simple reason - selecting all the items in destination list again just does not make any sense. And in case of when the destination list contains more items that fit in select area, the scrolling makes selecting those items very very annoying for random browser user who usually does not know the ctrl + click and shift + click selecting options.

So it comes down to comparing those use cases :

  1. User selects items from "from" select(1). User clicks add button(2). user saves selection (3)
  2. User selects items from "from" select(1). User clicks add button(2). User has to select all the selected items again (i have heard users say - why?! i just selected those items in last box, why do i have to select them again just to save my selection?) (3). User saves selection (4).

Case II makes even less sense cause without the jquery form.serialize() the widget works exactly as case I.

comment:5 by Julien Phalip, 13 years ago

Could you clarify what you mean by "user saves selection"? I am a bit confused why you need to select things from the destination list.

This widget is basically to select multiple items from a pool of available options (aka the "from" list). Once an item is moved to the destination list, then it is considered "selected" in the sense that the user has decided to pick that item from the available ones. So here the only purpose of selecting items (as in clicking or ctrl-clicking) is to move them from one list to the other.

Your use case seems to involve a third step, i.e. selecting items from the pool of already selected items (i.e. already the ones present in the destination list) to operate further operations. If that's the case, then I'm afraid this is beyond the scope of what was intended for this admin widget, and if you've already got an easy workaround to hack some extra functionality on top of it then that's great but that would remain your own responsibility.

comment:6 by Julien Phalip, 13 years ago

By the way, it would be interesting to hear if the patch in #16059 improves the general usability of that widget for you. It doesn't address the specific selection issue that you're reporting here though.

in reply to:  5 comment:7 by alan.kesselmann@…, 13 years ago

Type: BugNew feature

Replying to julien:

Could you clarify what you mean by "user saves selection"? I am a bit confused why you need to select things from the destination list.


By that i mean, the intent behind this widget - Its meant to make selection of items from list easyer. I mean that the "destination" list is initially a selection of items user wants to differentiate from the "source" list and save that selection.

This widget is basically to select multiple items from a pool of available options (aka the "from" list). Once an item is moved to the destination list, then it is considered "selected" in the sense that the user has decided to pick that item from the available ones. So here the only purpose of selecting items (as in clicking or ctrl-clicking) is to move them from one list to the other.


You are absolutely correct. When you look at it from the users point of view - the items in "destination" list are selected as far as user is concerned. But in HTML sense the items from 2nd list do not differ from the items in the first list, cause none of the options have "selected" attribute. And that "selected" attribute is that jquery .serialize() uses to pick up selection for saving. So if i wanted to post this form with ajax i would have to remind users to manually select items in "destination" list again - just so jQuery .serialize() would pick them up.

Your use case seems to involve a third step, i.e. selecting items from the pool of already selected items (i.e. already the ones present in the destination list) to operate further operations. If that's the case, then I'm afraid this is beyond the scope of what was intended for this admin widget, and if you've already got an easy workaround to hack some extra functionality on top of it then that's great but that would remain your own responsibility.


Yeah true again. I pondered over it and thought that this is not necessarily django bug but rather jquery .serialize() problem. Widget might work as intended, but in that case its not intended to be easyly posted with ajax and form serializing. And instead of beeing able to use existing widget (FilteredSelectMultiple) i would have to create my own with just this small difference.

I do not have a workaround for this widget. For my project i would have to create my own widget anyway. I propose though, that existing widget could be modified to keep options in "destination" list selected - which would eliminate the need for creating own widget just when you want to post this form with jquery.

Alan

comment:8 by Jacob, 13 years ago

Triage Stage: Design decision neededSomeday/Maybe

This is something that needs to be fixed. Sadly, it involves a fair bit of hacking on the select box JS, which is early, crufty, and fragile. Realistically this is more likely to be solved by the admin refresh/refactor we're starting to think about than by itself.

Thus, I'm marking this as "someday". Feel free to work on a patch, if you like, but I think attention would be better spent on the more general admin effort than this specific issue. There's probably a zillion like it, sadly.

Thanks!

comment:9 by Rik, 11 years ago

Keywords: nlsprint14 added
Owner: changed from nobody to Rik
Status: newassigned

comment:10 by Rik, 11 years ago

Owner: Rik removed
Status: assignednew

comment:11 by Baptiste Mispelon, 11 years ago

Easy pickings: unset

Removing the "easy picking" flag per jacbo's comment.

Note: See TracTickets for help on using tickets.
Back to Top