I think we're after the same thing but I'm not convinced that people
should be forced to use a blank item.
The example...

requires=[IS_IN_SET(['','English','Chinese','Italian']),IS_NOT_EMPTY
()]

...was just to show the flexibility that you can use multiple/
different validators and have an unsubmittable default ('Please
choose...') that wasn't a blank item.

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?

On Sep 5, 3:54 am, Iceberg <iceb...@21cn.com> wrote:
> Thanks for the feedback, but I would say:
>
>   requires=[IS_IN_SET(['','English','Chinese','Italian']),IS_NOT_EMPTY
> ()]
>
> is semantically inconsistent and therefore not intuitive. I still
> prefer to let the:
>
>   requires=IS_IN_SET(['English','Chinese','Italian'])
>
> can generate a drop-down list with initial blank, yet not accepting
> blank because the SET obviously contains no blank value.
>
> On Sep5, 4:00pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > I think SQLFORM should be changed to allow for IS_IN_SET with other
> > validators then you could just do:
> > requires=[IS_IN_SET(['','English','Chinese','Italian']),IS_NOT_EMPTY
> > ()]
>
> > Or you could get fancy:
> > requires=[IS_IN_SET(['Please
> > choose...','English','Chinese','Italian']),IS_EXPR("str(value) !=
> > 'Please choose...' ")]
>
> > It could just be a convention that requires[0] is IS_IN_SET (similar
> > to how IS_NULL_OR works currently).
>
> > On Sep 4, 11:58 pm, Iceberg <iceb...@21cn.com> wrote:
>
> > > Hi Massimo,
>
> > > My first web2py app is an order management system for my company, it
> > > worked well in enterprise production for more than 15 months now. By
> > > the way, all my other "first work of something" ended up as just a
> > > prototype but not this one, thank god and web2py. I am refactoring the
> > > app and going to share some ideas. Here comes the first one, about UI/
> > > UE aspect.
>
> > > Currently, if we write code like this:
> > >   db.Field('language', requires=IS_IN_SET
> > > (['English','Chinese','Italian']))
> > > it generates a drop-down list for three choices and the "English"
> > > appears as the first option.
>
> > > It is ok but, according to my long time observation, users who are
> > > facing a long form with dozens of fields, tend to finish each blank
> > > field one by one, but won't give enough attention to fields showing a
> > > default value. So it would be much better if the above example can be
> > > rendered as a drop-down list with 4 choices: an initial blank, then
> > > English, Chinese, Italian. Currently this can be done by:
> > >   db.Field('language', requires=IS_NULL_OR(IS_IN_SET
> > > (['English','Chinese','Italian'])))
> > > but with a side effect that the empty value is also acceptable,
> > > sometimes not what we want.
>
> > > So my proposal is to adjust OptionsWidget to always show up with an
> > > initial blank (when creating record), but not necessarily accepting
> > > it. Just change line 198 of sqlhtml.py from:
> > >   opts = []
> > > to:
> > >   if value:
> > >     opts = []
> > >   else: # To enforce an explicit choice when creating new record
> > >     opts = [OPTION(_value='')]
>
> > > Please give it a try and hope you will like it.
>
> > > Regards,
> > > Iceberg
--~--~---------~--~----~------------~-------~--~----~
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