Iceberg, did you see my previous message about inserting the option at
the *top* of the list?:

if value not in [k for k,v in options]:
            opts.insert(0, OPTION(value,_value=value))

What do you think?

On Sep 5, 1:46 pm, Iceberg <iceb...@21cn.com> wrote:
> I thought the change is so obvious that we don't need to "submit" a
> patch. But anyway, here it is.
>
> Index: sqlhtml.py
> ===================================================================
> --- sqlhtml.py  (revision 1196)
> +++ sqlhtml.py  (working copy)
> @@ -200,8 +200,9 @@
>              else:
>                  raise SyntaxError, 'widget cannot determine options
> of %s' \
>                      % field
> +        if value not in [k for k,v in options]:
> +            opts += [OPTION(value,_value=value)]
>          opts += [OPTION(v, _value=k) for (k, v) in options]
> -
>          return SELECT(*opts, **attr)
>
> On Sep6, 2:32am, "mr.freeze" <nat...@freezable.com> wrote:
>
> > Iceberg, do you want to submit a patch? Massimo, do you have any
> > issues with this change? I verified that it works when multiple=True
> > as well.
>
> > > > On Sep5, 11:51pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > > > > Perhaps a better solution is checking if the value for 'default'
> > > > > argument is *not* in the set and then appending it to the set but not
> > > > > allowing it to pass validation if selected.  What do you think?
>
> > > > You are a genius! This solution reaches the original goal without any
> > > > known side effect.
>
> > > > And the implementation is simple, too. Just add the following 2 lines
> > > > into OptionsWidget() 's widget(), one line before the final return.
> > > > Problem solved!
>
> > > >         if value not in [k for k,v in options]:
> > > >             opts += [OPTION(value,_value=value)]
>
> > > > Strongly recommended! Thanks Freeze!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to