Issue 768 <http://code.google.com/p/web2py/issues/detail?id=768>:Allow
insert of unsorted or unordered list:reference type field values
On Thu, Apr 19, 2012 at 5:08 PM, Richard Vézina <[email protected]
> wrote:

> Found this
> http://stackoverflow.com/questions/1867861/python-dictionary-keep-keys-values-in-same-order-as-declared
>  on
> stackoverflow where the most rated post redirect here :
> http://dev.pocoo.org/hg/sandbox/raw-file/tip/odict.py
>
> Notice, it will download odict.py into your computer that contain a class
> supposing to allow preservation of initial order in a python dict...
>
> I think, it could be nice to have this class added to web2py in order to
> allow insert into database of unordered list:reference field input...
>
> Since this could be slow (not in case of few value I think), it could be a
> choice offer to the user like : list:reference sorted or list:reference
> unsorted...
>
> What do you think??
>
> Richard
>
>
> On Thu, Apr 19, 2012 at 4:59 PM, Richard Vézina <
> [email protected]> wrote:
>
>> Some progress...
>>
>> I just make a check and chosen plugin multiple select option return a
>> unordered list of the picked element by the user...
>>
>> So, now, I think that it could be nice if web2py allow some way to
>> determine in case of use of chosen kind of plugin to store a unordered list
>> in list:reference field...
>>
>> I think that it is near line 207 (web2py 1.99.4) gluon/sqlhtml that we
>> have to make change :
>>
>> class OptionsWidget(FormWidget):
>>
>>     @staticmethod
>>     def has_options(field):
>>         """
>>         checks if the field has selectable options
>>
>>         :param field: the field needing checking
>>         :returns: True if the field has options
>>         """
>>
>>         return hasattr(field.requires, 'options')
>>
>>     @classmethod
>>     def widget(cls, field, value, **attributes):
>>         """
>>         generates a SELECT tag, including OPTIONs (only 1 option allowed)
>>
>>         see also: :meth:`FormWidget.widget`
>>         """
>>         default = dict(value=value) # HERE!!!!!!!!
>>
>> I am not pretty sure actually... And I don't really know, what could be
>> done to keep submit multiple list order in case of plugin use...
>>
>> I try naively to replace
>>
>> default = dict(value=value)
>>
>> By
>>
>> defautl = value
>>
>> But it failed.
>>
>> Richard
>>
>>
>>
>>
>> On Thu, Apr 19, 2012 at 3:43 PM, Richard Vézina <
>> [email protected]> wrote:
>>
>>> This is a part of the solution I think :
>>>
>>> http://www.ryancramer.com/journal/entries/select_multiple/
>>>
>>> Richard
>>>
>>>
>>> On Thu, Apr 19, 2012 at 3:08 PM, Richard <[email protected]>wrote:
>>>
>>>> Hello,
>>>>
>>>> I would know if there is a way to tell to list:reference to not order
>>>> the id of the reference table to keep the order in wich the user has pick
>>>> those element... At the same time I just thought that this concept is
>>>> useless except in case you use some javascript plugin like Chosen Multiple
>>>> Select (http://harvesthq.github.com/chosen/) because, you pick the
>>>> element in a list and there is no way to know which element in the list the
>>>> user has selected first.
>>>>
>>>> My need is to allow users to select element from an other table and
>>>> keep a more informative those selected thing. Like the ingredient on the
>>>> back panel of food box, the first ingredient more abondant than the second
>>>> an so on.
>>>>
>>>> So, for now I think I am stock with a text field. I would avoid a free
>>>> text field because I would prefer user to always use the same name for the
>>>> same thing, but I can't do it with text type field. What I thought is a
>>>> list:reference field and a button beside the field to allow allow user to
>>>> add missing element name in the foreign table if need without leave the
>>>> original form. This can be done easily with the select or add web2py slice
>>>> :
>>>> http://www.web2pyslices.com/slice/show/1446/widget-select-or-add-option.
>>>> Thanks to the author.
>>>>
>>>> But, I think that keeping the order of the selected element can't be
>>>> done??
>>>>
>>>> Thanks for help.
>>>>
>>>> Richard
>>>>
>>>
>>>
>>
>

Reply via email to