I have two tables which read like:

db.define_table('facility',
    db.Field
('facility',length=42,default='',notnull=True,unique=True),
    db.Field('in_widget',type='boolean',default=False,notnull=True),
    migrate='facility.table')


db.define_table('facilitytime',
    db.Field
('company',db.company,default='',notnull=True,ondelete='CASCADE'),
    db.Field('facility',length=42,default='',notnull=True),
    db.Field
('day',db.dag,default='',notnull=True,ondelete='RESTRICT'),
    db.Field('from_time',type='time',default='',notnull=True),
    db.Field('to_time',type='time',default='',notnull=True),
    db.Field('created_on',type='datetime'),
    db.Field('modified_on',type='datetime'),
    migrate='facilitytime.table')


Field facility in table facilitytime should be a options widget based
on the facility field in table facility. The facility should only be
contained in the widget when in_widget is True and key and value
should read the same.

I searched the group for an example but I couldn't find one I
completely understand.

I suppose in the model I need something like:

db.facilitytime.facility.widget=lambda f,v: facilitywidget(f,v,...)


the ... should be replaced with the facilities from this SQLRows
object:

facilityrows=db(db.faciliteit.in_widget==True).select
(db.faciliteit.faciliteit)


The widget should go in a module:

def facilitywidget(field,value,options):
        id='%s_%s' % (field._tablename,field.name)
        else: raise SyntaxError, "widget cannot determine options"
        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))


I hope one of you knows how to build this widget.


Kind regards,

Annet.
--~--~---------~--~----~------------~-------~--~----~
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