It is not in the manual.

give this:

db.mytest.person.requires=[IS_ALPHANUMERIC(),IS_NULL_OR(IS_IN_DB
(db,'dogs.dog_name', (dog_name)s'))]

you can do

class OptionsWidget:

    @staticmethod
    def has_options(field):
        return hasattr(field.requires, 'options')\
             or isinstance(field.requires, IS_NULL_OR)\
             and hasattr(field.requires.other, 'options')

    @staticmethod
    def widget(field, value):
        id = '%s_%s' % (field._tablename, field.name)
        if isinstance(field.requires, IS_NULL_OR)\
             and hasattr(field.requires.other, 'options'):
            opts = [OPTION(_value='')]
            options = field.requires[1].other.options()
        elif hasattr(field.requires, 'options'):
            opts = []
            options = field.requires.options()
        else:
            raise SyntaxError, 'widget cannot determine options of %s'
% field
        opts += [OPTION(v, _value=k) for (k, v) in options]
        return SELECT(*opts, **dict(_id=id, _class=field.type,
                      _name=field.name, value=value,
                      requires=field.requires))

db.mytest.person.widget=OptionWidget.widget

On May 25, 11:13 am, Timmie <timmichel...@gmx-topmail.de> wrote:
> First, thanks for you both to follow up!> 
> db.mytest.person.requires=[IS_ALPHANUMERIC(),IS_NULL_OR(IS_IN_DB
> > (db,'dogs.dog_name', (dog_name)s'))]
>
> > and I believe this is equivalent to what you want, except that it will
> > not display the dropbox without creating a custom widget to handle it.
>
> Well, I would use this as validator.
> But I definately need the drop-down box as it may show already
> existing values in the database.
>
> > not display the dropbox without creating a custom widget to handle it.
>
> Where can I start to create such a widget?
> I searched the manual and it only refers to widgets as GUI (TK)
> widgets.
>
> Regards,
> Timmie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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