Here is an example of using IS_IN_SET without a dropdown: form=SQLFORM.factory(Field('choice',requires=IS_IN_SET (('Yes','No','Maybe')),widget=SQLFORM.widgets.radio.widget))
On Sep 7, 11:23 am, "mr.freeze" <nat...@freezable.com> wrote: > Yeah, it doesn't feel as elegant (adds 8 lines instead of 2) but > having it in the validators means it can be used by custom widgets. > > On Sep 7, 11:11 am, Iceberg <iceb...@21cn.com> wrote: > > > I won't argue that whether just two lines of code would make a "too > > heavy" sqlhtml.py become "unacceptably heavy", but at least the > > IS_IN_DB does not benefit from the improvement if it is not > > implemented inside OptionsWidget. > > > By the way, would you give an example about "use the IS_IN_SET > > validator without having the dropdown"? > > > On Sep7, 11:55pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > for various reasons: > > > - sqlhtml is already too heavy, the more we delegate to the validators > > > and the wdgets the better > > > - because one should be able to do use the IS_IN_SET validator without > > > having the dropdown > > > > I added the missing like and uploading... > > > > Massimo > > > > On Sep 7, 10:50 am, "mr.freeze" <nat...@freezable.com> wrote: > > > > > It throws an error for IS_IN_DB. It's just missing 'self.zero = zero' > > > > in the __init__ function. It works after that. I'm curious though, > > > > why did you moved it from OptionsWidget to the validators? > > > > > On Sep 7, 10:25 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > I modified your patch. > > > > > > In trunk try this > > > > > > Field(...,requires=IS_IN_SET(('a','b','c'),zero=T('choose one'))) > > > > > > the option "zero" will be added at top but not accepted unless: > > > > > > Field(...,requires=IS_NULL_OR(IS_IN_SET(('a','b','c'),zero=T('choose > > > > > one')))) > > > > > > please give it a try. > > > > > > Massimo > > > > > > On Sep 5, 12:03 pm, Iceberg <iceb...@21cn.com> wrote: > > > > > > > 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 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 -~----------~----~----~----~------~----~------~--~---